-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
462 lines (415 loc) · 18.3 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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
buildscript {
if(JavaVersion.current() != JavaVersion.VERSION_12)
throw new GradleException("This build requires Java 12. Current SDK version is "+JavaVersion.current())
repositories {
mavenLocal()
jcenter()
maven { url "https://dl.bintray.com/stroom/stroom" }
}
dependencies {
// A fork of https://github.com/wfhartford/gradle-dependency-analyze that works with Java 10
// classpath 'stroom:gradle-dependency-analyze:v2.2.5'
classpath 'com.benjaminsproule:swagger-gradle-plugin:1.0.6'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
}
}
plugins {
// plugin for producing a tree of task dependencies, run task 'taskTree', e.g.
// ./gradlew bintrayUpload taskTree --no-repeat
id "com.dorongold.task-tree" version "1.3.1" apply true
}
//apply plugin: 'ca.cutterslade.analyze'
// if the project has a value for the passed property (i.e from the cmd line via -PpropName=xxx)
// use that, else use a default value
ext.getPropertyOrDefault = { propName, defaultValue ->
def val;
if (project.hasProperty(propName) && project.getProperty(propName) != "unspecified" && project.getProperty(propName) != "") {
val = project.getProperty(propName)
println "Using property [$propName] with value [$val]"
} else {
val = defaultValue
println "Property [$propName] has no value, using default value [$val]"
}
return val;
}
ext.versions = [
//----------Stroom-----------------
stroomQuery : getPropertyOrDefault('version', 'SNAPSHOT'),
//------Stroom-libs---------------
stroomExpression : 'v3.0.4',
eventLogging : 'v4.0.5_schema-v3.2.4',
//------------3rd-party------------
dropwizard : '1.3.14',
dropwizard_metrics: '4.0.5', // in line with dropwizard 1.3.14
flyway : '5.2.4',
glassfish : '2.5.0-b32',
javax_inject : '1',
javax_ws : '2.1',
jose4j : '0.5.2',
junit : '5.6.0',
kafka : '0.10.0.1',
swagger : '1.5.21',
zzDUMMYzz : 'makes sorting this list easier'
]
// dependency strings for use in sub projects
ext.libs = [
//------Stroom-libs---------------
eventLogging : "event-logging:event-logging:$versions.eventLogging",
stroomExpression : "stroom:stroom-expression:$versions.stroomExpression",
//------------3rd-party------------
assertj_core : 'org.assertj:assertj-core:3.10.0',
dropwizard_bom : "io.dropwizard:dropwizard-bom:$versions.dropwizard",
dropwizard_core : "io.dropwizard:dropwizard-core", // version controlled by DW BOM
dropwizard_db : "io.dropwizard:dropwizard-db", // version controlled by DW BOM
dropwizard_auth : "io.dropwizard:dropwizard-auth", // version controlled by DW BOM
dropwizard_auth_jwt : "com.github.toastshaman:dropwizard-auth-jwt:1.0.2-0",
dropwizard_logging : "io.dropwizard:dropwizard-logging", // version controlled by DW BOM
dropwizard_jersey : "io.dropwizard:dropwizard-jersey", // version controlled by DW BOM
dropwizard_flyway : 'io.dropwizard.modules:dropwizard-flyway:1.0.0-1',
dropwizard_metrics : "io.dropwizard.metrics:metrics-annotation:$versions.dropwizard_metrics",
dropwizard_testing : "io.dropwizard:dropwizard-testing", // version controlled by DW BOM
flyway_core : "org.flywaydb:flyway-core:$versions.flyway",
glassfish_hk2 : "org.glassfish.hk2:hk2-api:$versions.glassfish",
guava : "com.google.guava:guava", // version controlled by DW BOM
guice : "com.google.inject:guice:4.2.2:no_aop",
jackson_annotations : "com.fasterxml.jackson.core:jackson-annotations", // version controlled by DW BOM
jackson_core : "com.fasterxml.jackson.core:jackson-core", // version controlled by DW BOM
jackson_databind : "com.fasterxml.jackson.core:jackson-databind", // version controlled by DW BOM
javax_inject : "javax.inject:javax.inject:$versions.javax_inject",
javax_ws : "javax.ws.rs:javax.ws.rs-api:$versions.javax_ws",
javax_servlet : "javax.servlet:javax.servlet-api", // version controlled by DW BOM
javax_transaction : "javax.transaction:jta:1.1",
jaxb_api : "javax.xml.bind:jaxb-api:2.4.0-b180830.0359",
jaxb_runtime : "org.glassfish.jaxb:jaxb-runtime:2.4.0-b180830.0438",
jersey_client : "org.glassfish.jersey.core:jersey-client", // version controlled by DW BOM
jersey_server : "org.glassfish.jersey.core:jersey-server", // version controlled by DW BOM
jetty_http : "org.eclipse.jetty:jetty-http", // version controlled by DW BOM
junit_jupiter_api : "org.junit.jupiter:junit-jupiter-api:${versions.junit}",
junit_jupiter_engine: "org.junit.jupiter:junit-jupiter-engine:${versions.junit}",
jose4j : "org.bitbucket.b_c:jose4j:$versions.jose4j",
logback_classic : "ch.qos.logback:logback-classic", // version controlled by DW BOM
logback_core : "ch.qos.logback:logback-core", // version controlled by DW BOM
kafka : "org.apache.kafka:kafka-clients:$versions.kafka", // CDH5.10 uses kafka 10.0, Kafka <10.2 is picky about client and server versions.
mariadb_connector : 'org.mariadb.jdbc:mariadb-java-client:2.0.2',
mysql_connector : "mysql:mysql-connector-java:5.1.6",
mockito_core : "org.mockito:mockito-core:2.23.4",
slf4j_api : "org.slf4j:slf4j-api", // version controlled by DW BOM
swagger_annotations : "io.swagger:swagger-annotations:$versions.swagger",
test_containers : "org.testcontainers:testcontainers:1.12.0",
test_containers_mysql: "org.testcontainers:mysql:1.12.0",
ws_rs_api : "javax.ws.rs:javax.ws.rs-api:2.0.1",
wiremock : 'com.github.tomakehurst:wiremock:2.14.0',
zzDUMMYzz : "makes sorting easier"
]
// defines a list of gradle projects that we will publish with maven/bintray
def projectsToBePublished = subprojects.findAll { project ->
project.path in [
':stroom-docref',
':stroom-query-api',
':stroom-query-audit',
':stroom-query-authorisation',
':stroom-query-common',
'zzDUMMYzz to ease sorting'
]
}
allprojects {
}
subprojects {
apply plugin: 'java-library'
// apply plugin: 'ca.cutterslade.analyze'
apply plugin: 'idea'
sourceCompatibility = JavaVersion.VERSION_12
targetCompatibility = JavaVersion.VERSION_12
// This bit makes all sub projects have access to the BOMs for the dependency versions
dependencies {
compile platform(libs.dropwizard_bom)
}
repositories {
mavenLocal()
jcenter()
maven { url "https://dl.bintray.com/stroom/event-logging" }
maven { url "https://dl.bintray.com/stroom/stroom" }
}
test {
useJUnitPlatform()
}
task allDeps(type: DependencyReportTask) {}
// // Make dependency analyser work with java-library plugin.
// task analyzeJavaLibraryDependencies(dependsOn: classes, type: ca.cutterslade.gradle.analyze.AnalyzeDependenciesTask) {
// classesDirs = sourceSets.main.output.classesDirs
// require = [
//// project.configurations.api,
////project.configurations.compile,
//// project.configurations.compileClasspath,
// project.configurations.compile
// ]
// allowedToDeclare = [
// project.configurations.permitUnusedDeclared
// ]
// }
// task analyzeJavaLibraryTestDependencies(dependsOn: testClasses, type: ca.cutterslade.gradle.analyze.AnalyzeDependenciesTask) {
// classesDirs = sourceSets.test.output.classesDirs
// require = [
//// project.configurations.testApi,
// project.configurations.testCompile
//// project.configurations.testRuntimeClasspath
// ]
// allowedToDeclare = [
// project.configurations.permitTestUnusedDeclared
// ]
// allowedToUse = [
// project.configurations.runtimeClasspath
// ]
// }
//// task analyzeDeps(dependsOn: [analyzeJavaLibraryDependencies, analyzeJavaLibraryTestDependencies]) {
////
//// }
//
//// def mainTask = project.task('analyzeJavaLibraryDependencies',
//// dependsOn: 'classes',
//// type: AnalyzeDependenciesTask,
//// group: 'Verification',
//// description: 'Analyze project for dependency issues related to main source set.'
//// ) {
//// require = [
//// project.configurations.runtimeClasspath,
//// project.configurations.findByName('compileOnly'),
//// project.configurations.findByName('provided')
//// ]
//// allowedToUse = [
//// project.configurations.permitUsedUndeclared
//// ]
//// allowedToDeclare = [
//// project.configurations.permitUnusedDeclared
//// ]
//// def output = project.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).output
//// classesDirs = output.hasProperty('classesDirs') ? output.classesDirs : project.files(output.classesDir)
//// }
////
//// def testTask = project.task('analyzeTestClassesDependencies',
//// dependsOn: 'testClasses',
//// type: AnalyzeDependenciesTask,
//// group: 'Verification',
//// description: 'Analyze project for dependency issues related to test source set.'
//// ) {
//// require = [
//// project.configurations.testCompile,
//// project.configurations.findByName('testCompileOnly')
//// ]
//// allowedToUse = [
//// project.configurations.compile,
//// project.configurations.permitTestUsedUndeclared,
//// project.configurations.findByName('provided')
//// ]
//// allowedToDeclare = [
//// project.configurations.permitTestUnusedDeclared
//// ]
//// def output = project.sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME).output
//// classesDirs = output.hasProperty('classesDirs') ? output.classesDirs : project.files(output.classesDir)
//// }
////
//// project.check.dependsOn project.task('analyzeDeps',
//// dependsOn: [analyzeJavaLibraryDependencies, analyzeJavaLibraryTestDependencies],
//// group: 'Verification',
//// description: 'Analyze project for dependency issues.'
//// )
////
// tasks.analyzeJavaLibraryDependencies.dependsOn(classes)
// tasks.analyzeJavaLibraryTestDependencies.dependsOn(testClasses)
// tasks.check.dependsOn(analyzeJavaLibraryDependencies)
// tasks.check.dependsOn(analyzeJavaLibraryTestDependencies)
configurations {
// ensure deps don't bring any logging implementations with them as this will
// conflict with logback. Also replace any log4j deps with log4j-over-slf4j
// so dependency jars work with slf4j
all {
// exclude group: "javax.annotation", module: "javax.annotation-api"
exclude group: "org.glassfish.hk2.external", module: "aopalliance-repackaged"
exclude group: "commons-logging", module: "commons-logging"
// exclude group: "org.jboss.logging", module: "jboss-logging"
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
// exclude group: "com.google.guava", module: "guava"
// exclude group: "ch.qos.logback", module: "logback-core"
// exclude group: "log4j", module: "log4j"
// exclude group: "commons-logging", module: "commons-logging"
// exclude module: 'xercesImpl'
//
resolutionStrategy {
// dependencySubstitution {
//// substitute module('log4j:log4j') with module("org.slf4j:log4j-over-slf4j:$versions.slf4j")
// substitute module('com.google.guava:guava') with module("com.google.guava:guava:$versions.guava")
// }
//
// // Stop libs from dragging in a different version of dropwizard
// eachDependency { DependencyResolveDetails details ->
// if (details.requested.group == 'io.dropwizard') {
// details.useVersion versions.dropwizard
// }
// if (details.requested.group == 'io.dropwizard.metrics') {
// details.useVersion versions.dropwizard_metrics
// }
// }
}
}
}
afterEvaluate {
// compileJava {
// inputs.property("moduleName", moduleName)
// doFirst {
// options.compilerArgs = [
// '--module-path', classpath.asPath,
// ]
// classpath = files()
// }
// }
//
// compileTestJava {
// inputs.property("moduleName", moduleName)
// doFirst {
// options.compilerArgs = [
// '--module-path', classpath.asPath,
//// '--add-modules', 'junit',
//// '--add-reads', "$moduleName=junit",
// '--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
// ]
// classpath = files()
// }
// }
//
// test {
// inputs.property("moduleName", moduleName)
// doFirst {
// jvmArgs = [
// '--module-path', classpath.asPath,
// '--add-modules', 'ALL-MODULE-PATH',
//// '--add-reads', "$moduleName=junit",
// '--patch-module', "$moduleName=" + files(sourceSets.test.java.outputDir).asPath,
// ]
// classpath = files()
// }
// }
//
// javadoc {
// options.addStringOption('-module-path', classpath.asPath)
// options.addStringOption('Xdoclint:all,-missing', '-html5')
// }
}
}
// configures only those projects in publishedProjectsPaths
configure(projectsToBePublished) {
println "Configuring ${project.path} for publishing"
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
group = 'stroom'
version = versions.stroomQuery
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
scm {
url "https://github.com/stroom/stroom-query"
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc {
// this switch is needed in java 10
// options.addBooleanOption('html5', true)
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
afterEvaluate {
jar {
inputs.property("moduleName", moduleName)
manifest {
attributes(
"Automatic-Module-Name": moduleName,
)
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact sourcesJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', project.name)
root.children().last() + pomConfig
}
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
// configuration for the bintray plugin for uploading maven artefacts to bintray
// see https://github.com/bintray/gradle-bintray-plugin
// run task bintrayUpload to push the files, assuming BINTRAY_USER/KEY are set as env vars
bintray {
// Must never write these to log or system out
user = System.getenv('BINTRAY_USER') // set in Travis UI
key = System.getenv('BINTRAY_KEY') // set in Travis UI
// The maven plugin publications to push to bintray
publications = ['mavenJava']
// immediately make the artefacts public
publish = true
pkg {
repo = 'stroom'
name = 'stroom-query'
userOrg = 'stroom'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/gchq/stroom-query.git'
version {
name = "${versions.stroomQuery}"
desc = "stroom-query-${versions.stroomQuery}"
released = new Date()
vcsTag = "${versions.stroomQuery}"
gpg {
// Bintray will self-sign the files
sign = true // Determines whether to GPG sign the files. The default is false
}
}
}
}
}
task aggregatedJavadocs(
type: Javadoc,
description: 'Generate javadocs from all child projects as if it was a single project',
group: 'Documentation') {
destinationDir = file("$buildDir/docs/javadoc")
title = "$project.name $version API"
options.author true
// options.links 'https://docs.oracle.com/javase/8/docs/api/'
options.addStringOption 'Xdoclint:none', '-quiet'
// this switch is needed in java10
// options.addBooleanOption('html5', true)
projectsToBePublished.each { proj ->
proj.tasks.withType(Javadoc).each { javadocTask ->
source += javadocTask.source
classpath += javadocTask.classpath
excludes += javadocTask.excludes
includes += javadocTask.includes
}
}
}
project(':stroom-query-common').tasks.build.dependsOn aggregatedJavadocs