forked from termsuite/termsuite-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
403 lines (333 loc) · 11.2 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
129
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.standardout:bnd-platform:1.4.0'
classpath "net.saliman:gradle-properties-plugin:1.4.5"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'maven-publish'
apply plugin: 'org.standardout.bnd-platform'
apply plugin: 'net.saliman.properties'
apply plugin: 'com.jfrog.bintray'
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
repositories {
mavenLocal()
mavenCentral()
}
sourceSets {
eval
}
sourceSets {
corpora
}
///////////////////////////////////////////////////////////////// CONFIGURATION
javadoc{
exclude '**/fr/univnantes/termsuite/types/**'
options {
failOnError = false
encoding "UTF-8"
docEncoding "UTF-8"
charSet "UTF-8"
}
}
// Remove javadoc warnings
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
////////////////////////////////////////////////////////////////// TASKS
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
//////////////////////////////////////////////////////////////////
// JCASGEN
// Author: Damien Raude-Morvan
//
// Generate UIMA type system
//////////////////////////////////////////////////////////////////
configurations {
prepare.extendsFrom(compile)
}
task jcasgen(type: JavaExec) {
description = 'Generate UIMA TS classes'
ext.srcFile = file("$projectDir/src/main/resources/TermSuite_TS.xml")
ext.outputDir = file("$projectDir/src/main/java")
inputs.file srcFile
outputs.dir outputDir
classpath configurations.prepare
// This ensures availability of type system imports
// however, assumes that files are in desc subfolder
systemProperty 'uima.datapath', "$projectDir/desc"
main = 'org.apache.uima.tools.jcasgen.Jg'
args = ['-jcasgeninput', srcFile, '-jcasgenoutput', outputDir]
}
// forces jcasgen before java compiles
classes.dependsOn jcasgen
updateSiteZip.dependsOn clean, jar
// UIMA type system is needed for Java compile
compileJava.source jcasgen.outputs, sourceSets.main.java
// Produces OSGi bundles and P2 update site
platform {
fetchSources = false
featureId=project.getProperty("termsuite.osgi.feature.id")
featureName=project.getProperty("termsuite.osgi.feature.name")
featureVersion=version
/*
* TODO: set eclipseMirror property instead of
* (or in addition to) eclipseHome in order to be
* able to run it from CI servers.
*
*/
eclipseHome = new File(project.getProperty("user.eclipse.home"))
bundle(project) {
bnd {
symbolicName = project.getProperty("osgi.plugin.symbolicName")
bundleName = project.getProperty("osgi.bundleName")
version = project.getProperty("version")
addQualifier = version.endsWith('SNAPSHOT')
instruction "Import-Package", ""
instruction "Export-Package", "fr.univnantes.termsuite.*,org.apache.uima.examples"
}
}
feature(id: project.getProperty("termsuite.thirdparty.osgi.feature.id"), name: project.getProperty("termsuite.thirdparty.osgi.feature.name"), version: version) {
plugin "ch.qos.logback:logback-classic:1.1.7"
plugin "com.google.guava:guava:21.0"
}
}
artifacts {
archives javadocJar, sourcesJar
}
if(hasProperty("signing.keyId")
&& hasProperty("signing.secretKeyRingFile")
&& new File(project.getProperty("signing.secretKeyRingFile")).exists()
) {
// activate signing of artifacts, only if signing is configured properly
signing {
sign configurations.archives
}
}
publishing {
publications {
maven(MavenPublication) {
groupId project.getProperty("group")
artifactId project.getProperty("name")
version project.getProperty("version")
from components.java
artifact sourcesJar {
classifier "sources"
}
}
}
}
if(hasProperty("ossrh.username")) {
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: project.getProperty("oss.repository.release")) {
authentication(userName: project.getProperty("ossrh.username"), password: project.getProperty("ossrh.password"))
}
snapshotRepository(url: project.getProperty("oss.repository.snapshot")) {
authentication(userName: project.getProperty("ossrh.username"), password: project.getProperty("ossrh.password"))
}
pom.project {
name project.getProperty("name")
packaging 'jar'
// optionally artifactId can be defined here
description project.getProperty("description")
url project.getProperty("url")
scm {
connection "scm:git:" + project.getProperty("termsuite.git.url")
developerConnection "scm:git:" + project.getProperty("termsuite.git.url")
url project.getProperty("termsuite.git.url")
}
licenses {
license {
name project.getProperty("license")
url project.getProperty("licenseUrl")
}
}
developers {
developer {
id project.getProperty("developer.id")
name project.getProperty("developer.name")
email project.getProperty("developer.email")
}
}
}
}
}
}
} else {
def msg = "Publishing to maven central (task uploadArchives) is not possible since no gradle property file is found (use \"\$ cp gradle.properties.sample gradle.properties\" and edit gradle.properties)"
logger.warn(msg)
}
dependencies {
// Test
testCompile "junit:junit:4.12"
testCompile "eu.codearte.catch-exception:catch-exception:1.4.4"
testCompile "org.assertj:assertj-core:3.8.0"
testCompile "org.mockito:mockito-core:2.8.9"
// Configure logging at runtime
compile "ch.qos.logback:logback-classic:1.1.7"
// Json
compile "com.fasterxml.jackson.core:jackson-databind:2.8.6"
compile "com.fasterxml.jackson.core:jackson-annotations:2.8.6"
// Xodus
compile 'org.jetbrains.xodus:xodus-entity-store:1.0.2'
// UIMA
/*
* Warning: upgrading to uimafit-core:2.2.0 and uimaj-core:2.9.0
* causes a ConcurrentModificationException in Lexer
*/
compile "org.apache.uima:uimaj-core:2.10.0"
compile "org.apache.uima:uimafit-core:2.3.0"
// Apache Common
compile "org.apache.commons:commons-lang3:3.4"
compile "commons-cli:commons-cli:1.2"
compile "commons-io:commons-io:1.3.2"
// Mate Tagger
compile "com.googlecode.mate-tools:anna:3.5"
// Groovy
compile "org.codehaus.groovy:groovy:2.4.4"
// Guava
compile "com.google.guava:guava:21.0"
// Guice
compile 'com.google.inject:guice:4.1.0'
// Snake YAML
compile "org.yaml:snakeyaml:1.15"
// Jackson (json)
compile "com.fasterxml.jackson.core:jackson-core:2.5.4"
// UIMA Components
compile 'fr.univ-nantes.julestar:uima-tree-tagger-wrapper:1.3'
compile 'fr.univ-nantes.julestar:uima-tokenizer:1.4'
compile 'fr.univ-nantes.julestar:uima-filter:1.2'
compile 'fr.univ-nantes.julestar:uima-mapper:1.2'
compile 'fr.univ-nantes.julestar:uima-chinese-segmenter:1.3'
compile 'fr.univ-nantes.julestar:uima-tokens-regex:1.4'
compile 'fr.univ-nantes.julestar:uima-stemmer:1.2'
compile 'fr.univ-nantes.julestar:uima-toolbox:1.0'
// JCas type generation
prepare "org.apache.uima:uimaj-tools:2.8.1"
}
test {
/*
* explicitly exclude functional tests from default gradle build
*/
exclude 'fr/univnantes/termsuite/test/func/**'
}
/*
* Launches unit tests manually
*/
task unitTest( type: Test ) {
exclude 'fr/univnantes/termsuite/test/func/**'
}
/*
* Launches cucumber tests manually
*/
task cucumberTest( type: Test ) {
/*
* explicitly runs functional tests
*/
include 'fr/univnantes/termsuite/test/func/**'
exclude 'fr/univnantes/termsuite/test/unit/**'
}
/*
* Enforces the run of cucumber tests before uploading archives
*/
//uploadArchives.dependsOn cucumberTest
////////////////////////////////////////////////////////////// SPECIFIC TASKS
jar {
// make it fat
dependsOn configurations.runtime
from( configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } ) {
exclude "META-INF/*"
}
exclude "**/lv/**"
// cannot exclude META-INF for groovy to run
from( configurations.runtime.findAll{it.getAbsolutePath().contains("org.codehaus.groovy")}.collect { it.isDirectory() ? it : zipTree(it) } ) {
include "META-INF/*"
}
// tune manifest
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Version": project.getProperty("version"),
"Built-By": System.getProperty('user.name'),
"Built-Date": new Date(),
"Built-JDK": System.getProperty('java.version'),
"Main-Class": "fr.univnantes.termsuite.tools.TerminologyExtractorCLI")
}
}
compileJava.doFirst{
def termsuiteVersion = file("src/main/resources/TERMSUITE_VERSION").text
if(!termsuiteVersion.equals(project.getProperty("version"))) {
println "Version in gradle property: " + project.getProperty("version")
println "Version TERMSUITE_VERSION: " + termsuiteVersion
throw new GradleException("TermSuite versions differ! Version in gradle property: " + project.getProperty("version") + ". Version in TERMSUITE_VERSION: " + termsuiteVersion)
}
}
clean.doLast {
project.delete (fileTree(dir: 'sources/fr/univnantes/termsuite/types'))
project.delete (fileTree(dir: 'sources/org')) // org.apache.uima.examples
println 'Cleaning typesystem generated sources.'
}
/*
* Upload the update site on bintray
*
* WARNING: Not yet working due to issue on gradle-bintray-plugin:
* https://github.com/bintray/gradle-bintray-plugin/issues/142#issuecomment-247398758
*
* Please use the curl (and OS-dependant) task uploadP2 instead.
*
*/
bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
publish = true
override = true
filesSpec {
from 'build/updatesite/'
into '.'
}
pkg {
repo = project.getProperty("termsuite.p2repo.name")
name = project.getProperty("termsuite.p2repo.pkgname")
desc = project.getProperty("termsuite.p2repo.description")
userOrg = project.getProperty("termsuite.bintray.org")
licenses = [project.getProperty("license")]
vcsUrl = project.getProperty("termsuite.git.url")
labels = project.getProperty("termsuite.p2repo.tags").split(",")
publicDownloadNumbers = false
version {
name = version
released = new Date()
}
}
}
bintrayUpload.dependsOn updateSiteZip
/*
* Upload the update-site on bintray.
*
* WARNING: this task is OS-dependant. It must be suppressed when
* the bintrayUpload task is debugged.
*/
task uploadP2(type: Exec) {
workingDir = "./"
commandLine "curl", "-T", "build/updatesite.zip", "-u$bintrayUser:$bintrayApiKey", "https://api.bintray.com/content/termsuite/termsuite-ui/update-site/$version/updatesite.zip?publish=1&override=1&explode=1"
}
uploadP2.dependsOn updateSiteZip