build.gradle 7.48 KB
Newer Older
Gradl, Tobias's avatar
Gradl, Tobias committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
buildscript {
    repositories {
        //maven { url 'https://repo.spring.io/plugins-snapshot' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        //classpath 'io.spring.gradle:dependency-management-plugin'
        classpath 'com.netflix.nebula:gradle-ospackage-plugin'
    }
}

plugins {
    id 'war'
    //id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'maven-publish'
Gradl, Tobias's avatar
Gradl, Tobias committed
16
    id 'nebula.ospackage' version '8.3.0'
Gradl, Tobias's avatar
Gradl, Tobias committed
17
18
19
20
}

allprojects {
    group = 'eu.dariah.de.minfba'
21
    version = '3.9.4-SNAPSHOT'
Gradl, Tobias's avatar
Gradl, Tobias committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    description = 'DARIAH-DE Generic Search'
    
    ext {
        mavenRepo     = 'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
        releasesRepo  = "https://minfba.de.dariah.eu/nexus/repository/minfba-releases/"
        snapshotsRepo = "https://minfba.de.dariah.eu/nexus/repository/minfba-snapshots/"
        aptRepo       = 'https://minfba.de.dariah.eu/nexus/repository/minfba-apt/'
        yumRepo       = 'https://minfba.de.dariah.eu/nexus/repository/minfba-yum/'
        
        repoUser = project.hasProperty('nexususer') ? project.getProperty('nexususer') : '?';
        repoPass = project.hasProperty('nexuspass') ? project.getProperty('nexuspass') : ''
    }
}

repositories {
    mavenLocal()
    maven {
        url = mavenRepo
    }
}

sourceCompatibility = '1.8'

ext {
46
    searchCommonsVersion = "1.19.4-SNAPSHOT"
Gradl, Tobias's avatar
Gradl, Tobias committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60

    springVersion = "4.3.6.RELEASE"
        hibernateValidatorVersion = "5.2.2.Final"
        tilesVersion = "3.0.5"
        slf4jVersion = "1.7.25"
        httpComponentsVersion = "4.5.5"
        logbackVersion = "1.2.3"

    // Filled dynamically by packaging tasks
    debFile = ""
    rpmFile = ""
}

dependencies {
Gradl, Tobias's avatar
Gradl, Tobias committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    compile "eu.dariah.de.minfba:search-commons:$searchCommonsVersion"
    compile "org.springframework:spring-context:$springVersion"
    compile "org.springframework:spring-beans:$springVersion"
    compile "org.springframework:spring-core:$springVersion"
    compile "org.springframework:spring-webmvc:$springVersion"
    compile "org.springframework:spring-web:$springVersion"
    //compile "org.springframework.security:spring-security-core:4.2.1.RELEASE"
    //compile "org.springframework.security:spring-security-web:4.2.1.RELEASE"
    //compile "org.springframework.security:spring-security-config:4.2.1.RELEASE"
    compile "org.apache.httpcomponents:httpclient:$httpComponentsVersion"
    compile "org.apache.tiles:tiles-core:$tilesVersion"
    compile "org.apache.tiles:tiles-jsp:$tilesVersion"
    compile "org.apache.tiles:tiles-api:$tilesVersion"
    compile "org.slf4j:slf4j-api:$slf4jVersion"
    compile "ch.qos.logback:logback-core:$logbackVersion"
    compile "ch.qos.logback:logback-classic:$logbackVersion"
    compile "javax.servlet:jstl:1.2"
    compile "org.yaml:snakeyaml:1.18"
79
80
81
    runtime "org.slf4j:jcl-over-slf4j:$slf4jVersion"
    runtime "org.slf4j:log4j-over-slf4j:$slf4jVersion"
    runtime "org.apache.logging.log4j:log4j-to-slf4j:2.7"
Gradl, Tobias's avatar
Gradl, Tobias committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    testImplementation "org.springframework:spring-test:$springVersion"
    testImplementation "junit:junit:4.12"
    testImplementation "org.mockito:mockito-all:1.10.19"
    providedCompile "javax.servlet:servlet-api:2.5"
    providedCompile "javax.servlet.jsp:jsp-api:2.1"
}


java {
    sourceCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

tasks.withType(Deb) {
    dependsOn(classes)
    doLast {
        project.debFile = archiveName;
    }
}

tasks.withType(Rpm) {
    dependsOn(classes)
    doLast {
        project.rpmFile = archiveName;
    }
}

ospackage {
    os = LINUX
Gradl, Tobias's avatar
Gradl, Tobias committed
129
    arch = 'all'
Gradl, Tobias's avatar
Gradl, Tobias committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
    packageName "dariah-$project.name"
    replaces "$project.name"
    maintainer 'info@de.dariah.eu'
    requires('openjdk-8-jdk').or('openjdk-11-jdk')
    signingKeyId('CB012F105B632B46C2A7B4918FC46DAC1BC3E238')

    into "var/dfa/webapps/$project.name/"

    from(configurations.runtime) {
        into "WEB-INF/lib"
    }

    from("$buildDir/classes/java/main") {
        into "WEB-INF/classes"
    }

    from ("src/main/resources") {
        into "WEB-INF/classes"
    }

    from ("src/main/webapp/WEB-INF") {
        into "WEB-INF"
    }

    from ("src/main/webapp/resources") {
        into "resources"
    }

    from ("src/main/webapp/themes") {
        into "themes"
    }

    from ("src/main/webapp/META-INF") {
        into "META-INF"
    }
}

publishing {
    publications {
        maven(MavenPublication) {
            from(components.web)
            artifact(sourcesJar) {}
            artifact(javadocJar) {}
            pom {
                name = 'DARIAH-DE Generic Search'
                url = 'https://gitlab.rz.uni-bamberg.de/dariah/search'
                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id = 'tgradl'
                        name = 'Tobias Gradl'
                        email = 'tobias.gradl@uni-bamberg.de'
                    }
                }
                scm {
                    connection = 'scm:git:git://gitlab.rz.uni-bamberg.de/dariah/search.git'
                    developerConnection = 'scm:git:ssh://gitlab.rz.uni-bamberg.de/dariah/search.git'
                    url = 'https://gitlab.rz.uni-bamberg.de/dariah/search'
                }
                issueManagement {
                    system = 'GitLab'
                    url = 'https://gitlab.rz.uni-bamberg.de/dariah/search/issues'
                }
            }
        }
    }
    repositories {
        maven {            
            if (version.endsWith('SNAPSHOT') || version.endsWith('RELEASE')) {
                credentials {
                    username repoUser
                    password repoPass
                }
                url = version.endsWith('SNAPSHOT') ? snapshotsRepo : releasesRepo
            } else {
                // Have a local test repo under buildDir to be able to test publish but only actually do publish when the version ending matches
                url = "$buildDir/repo/"
            }
        }
    }
}

task publishDebPackage {
    dependsOn buildDeb
    def distroPath = "$buildDir/distributions/"
    doLast {
        if (version.endsWith('SNAPSHOT') || version.endsWith('RELEASE')) {
            println "Publishing Debian package $debFile as user $repoUser";
            exec {
                executable "curl"
                args "-f", "-u", "$repoUser:$repoPass", "-H", "Content-Type: multipart/form-data", "--data-binary", "@$distroPath$debFile", "$aptRepo";
            }
        }
    }
}

task publishRpmPackage {
    dependsOn buildRpm
    def distroPath = "$buildDir/distributions/"
    doLast {
        if (version.endsWith('SNAPSHOT') || version.endsWith('RELEASE')) {
            println "Publishing Rpm package $rpmFile as user $repoUser";
            exec {
                executable "curl"
                args "-f", "-u", "$repoUser:$repoPass", "--upload-file", "$distroPath$rpmFile", "$yumRepo/dariah/${project.name}/${project.version}/$rpmFile";
            }
        }
    }
}

publish.finalizedBy publishDebPackage
Gradl, Tobias's avatar
Gradl, Tobias committed
246
//publish.finalizedBy publishRpmPackage