forked from micronaut-projects/micronaut-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
628 lines (574 loc) · 24.5 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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
buildscript {
repositories {
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails:grails-docs:$grailsVersion"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
classpath 'io.github.groovylang.groovydoc:groovydoc-gradle-plugin:1.0.1'
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.2'
classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:1.0.0"
classpath "gradle.plugin.org.aim42:htmlSanityCheck:$htmlSanityCheckVersion"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.1"
classpath 'javax.xml.bind:jaxb-api:2.2.8'
classpath "io.micronaut.docs:micronaut-docs-asciidoc-extensions:$micronautDocsVersion"
classpath "io.micronaut.docs:micronaut-docs-gradle-plugins:$micronautDocsVersion", {
exclude module:'shadow'
exclude module:'plugin-shadow'
}
}
}
plugins {
id 'com.github.hierynomus.license' version '0.14.0' apply false
}
apply plugin: "io.sdkman.vendors"
apply plugin: 'org.aim42.htmlSanityCheck'
repositories {
maven { url "https://repo.grails.org/grails/core" }
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
version project.projectVersion
ext {
distInstallDir = file("$buildDir/dist-tmp")
homeBinDir = file("bin")
homeLibDir = file("lib")
homeSrcDir = file("src")
}
ext {
dependencyVersions = [
groovy : [
version: groovyVersion,
group : 'org.codehaus.groovy',
name : 'groovy',
modules: ['groovy-test', 'groovy-ant', 'groovy-json', 'groovy-jmx', 'groovy-templates']
],
gorm : [
version: gormVersion,
group : 'org.grails',
name : 'grails-datastore-core',
modules: ['grails-datastore-gorm', 'grails-datastore-gorm-hibernate5']
],
jackson : [
version: jacksonVersion,
group : 'com.fasterxml.jackson.core',
name : 'jackson-databind',
modules: ['jackson-core', 'jackson-annotations']
],
'jackson.modules' : [
version: jacksonVersion,
group : 'com.fasterxml.jackson.module',
name : 'jackson-module-afterburner'
],
'jackson.datatype' : [
version: jacksonVersion,
group : 'com.fasterxml.jackson.datatype',
name : 'jackson-datatype-jdk8',
modules: ['jackson-datatype-jsr310']
],
jaeger : [
version: jaegerVersion,
group : 'io.jaegertracing',
name : 'jaeger-thrift'
],
'zipkin.reporter' : [
version: zipkinReporterVersion,
group : 'io.zipkin.reporter2',
name : 'zipkin-reporter'
],
'brave.instrumentation' : [
version: braveInstrumentationHttpVersion,
group : 'io.zipkin.brave',
name : 'brave-instrumentation-http'
],
'brave.opentracing' : [
version: braveOpentracingVersion,
group : 'io.opentracing.brave',
name : 'brave-opentracing'
],
'javax.annotation-api' : [
version: javaxAnnotationApiVersion,
group : 'javax.annotation',
name : 'javax.annotation-api'
],
jsr305 : [
version: jsr305Version,
group : 'com.google.code.findbugs',
name : 'jsr305'
],
kafka : [
version: kafkaVersion,
group : 'org.apache.kafka',
name : 'kafka-clients',
modules: ['kafka_2.12', 'kafka-streams']
],
'micronaut.grpc' : [
version: micronautGrpcVersion,
group : 'io.micronaut.grpc',
name : 'micronaut-grpc-runtime',
modules: ['micronaut-grpc-annotation']
],
'micronaut.test' : [
version: micronautTestVersion,
group : 'io.micronaut.test',
name : 'micronaut-test-core',
modules: ['micronaut-test-spock', 'micronaut-test-junit5']
],
'micrometer' : [
version: micrometerVersion,
group : 'io.micrometer',
name : 'micrometer-core',
modules: ['micrometer-registry-atlas', 'micrometer-registry-graphite', 'micrometer-registry-prometheus', 'micrometer-registry-statsd']
],
'mongo' : [
version: mongoVersion,
group : 'org.mongodb',
modules: ['mongodb-driver-async', 'mongo-java-driver']
],
'mongo.reactive' : [
version: '1.8.0',
group : 'org.mongodb',
name : 'mongodb-driver-reactivestreams'
],
neo4j : [
version: neo4jVersion,
group : 'org.neo4j.test',
name : 'neo4j-harness'
],
'neo4j.bolt' : [
version: '1.6.2',
group : 'org.neo4j.driver',
name : 'neo4j-java-driver'
],
'jcache' : [
version: jcacheVersion,
group : 'javax.cache',
name : 'cache-api'
],
netty : [
version: nettyVersion,
group : 'io.netty',
name : 'netty-codec-http',
modules: ['netty-all', 'netty-buffer', 'netty-codec', 'netty-codec-dns', 'netty-codec-haproxy',
'netty-codec-http2', 'netty-codec-memcache', 'netty-codec-mqtt',
'netty-codec-redis', 'netty-codec-smtp', 'netty-codec-socks', 'netty-codec-stomp',
'netty-codec-xml', 'netty-common', 'netty-dev-tools', 'netty-handler',
'netty-handler-proxy', 'netty-resolver', 'netty-resolver-dns', 'netty-transport',
'netty-transport-rxtx', 'netty-transport-sctp', 'netty-transport-udt']
],
opentracing : [
version: '0.31.0',
group : 'io.opentracing',
name : 'opentracing-api',
modules: ['opentracing-util']
],
picocli : [
version: picocliVersion,
group : 'info.picocli',
name : 'picocli'
],
lettuce : [
version: lettuceVersion,
group : 'io.lettuce',
name : 'lettuce-core'
],
spring : [
version: springVersion,
group : 'org.springframework',
name : 'spring-core',
modules: ['spring-context', 'spring-tx', 'spring-orm', 'spring-jdbc']
],
snakeyaml : [
version: yamlVersion,
group : 'org.yaml',
name : 'snakeyaml'
],
slf4j : [
version: slf4jVersion,
group : 'org.slf4j',
name : 'slf4j-api',
modules: ['slf4j-simple']
],
spock : [
version: spockVersion,
group : 'org.spockframework',
name : 'spock-core'
],
swagger : [
version: '2.0.4',
group : 'io.swagger.core.v3',
name : 'swagger-core',
modules: ['swagger-models', 'swagger-annotations']
],
'reactive.streams' : [
version: reactiveStreamsVersion,
group : 'org.reactivestreams',
name : 'reactive-streams'
],
'reactive.pg.client' : [
version: reactivePgClientVersion,
group : 'io.reactiverse',
name : 'reactive-pg-client'
],
rxjava1 : [
version: rxJava1Version,
group : 'io.reactivex',
name : 'rxjava'
],
'rxjava1.interop' : [
version: rxJavaInteropVersion,
group : 'com.github.akarnokd',
name : 'rxjava2-interop'
],
rxjava2 : [
version: rxJava2Version,
group : 'io.reactivex.rxjava2',
name : 'rxjava'
],
reactor : [
version: reactorVersion,
group : 'io.projectreactor',
name : 'reactor-core'
],
validation : [
version: validationVersion,
group : 'javax.validation',
name : 'validation-api'
],
hystrix : [
version: hystrixVersion,
group : 'com.netflix.hystrix',
name : 'hystrix-core',
modules: ['hystrix-serialization']
],
graal : [
version: graalVersion,
group : 'com.oracle.substratevm',
name : 'svm'
],
h2 : [
version: h2Version,
group : 'com.h2database',
name : 'h2'
],
tomcatJdbc : [
version: tomcatJdbcVersion,
group : 'org.apache.tomcat',
name : 'tomcat-jdbc'
],
liquibase : [
version: liquibaseVersion,
group : 'org.liquibase',
name : 'liquibase-core'
],
flyway : [
version: flywayVersion,
group : 'org.flywaydb',
name : 'flyway-core'
],
jna : [
version: jnaVersion,
group : 'net.java.dev.jna',
name : 'jna'
],
hibernate : [
version: hibernateVersion,
group : 'org.hibernate',
name : 'hibernate-core',
modules: ['hibernate-jcache', 'hibernate-ehcache']
],
'methvin.directory-watcher': [
version: methvinDirectoryWatcherVersion,
group : 'io.methvin',
name : 'directory-watcher'
]
]
dependencyVersion = { String name ->
def dep = dependencyVersions[name]
if (dep == null) {
throw new IllegalArgumentException("No core dependency defined for name: $name")
}
return "$dep.group:$dep.name:$dep.version".toString()
}
dependencyModuleVersion = { String name, String module ->
def dep = dependencyVersions[name]
if (dep == null) {
throw new IllegalArgumentException("No core dependency defined for name: $name")
}
return "$dep.group:$module:$dep.version".toString()
}
}
task testReportsAggregate {
group 'verification'
doLast() {
int totalFailures = 0
int totalErrors = 0
int totalSkipped = 0
int totalTests = 0
int itemPad = 13
int titlePad = 35
String separator = " | "
subprojects.each { subproject ->
if (subproject.tasks.find { Task task -> task.name == 'test' }) {
if (new File("${subproject.buildDir}/test-results/test").exists()) {
int failures = 0
int errors = 0
int skipped = 0
int tests = 0
new File("${subproject.buildDir}/test-results/test").eachFile() { file ->
if (file.name.endsWith('.xml')) {
def testsuite = new XmlSlurper().parseText(file.text)
failures += "${testsuite['@failures']}" as int
errors += "${testsuite['@errors']}" as int
skipped += "${testsuite['@skipped']}" as int
tests += "${testsuite['@tests']}" as int
}
}
totalFailures += failures
totalErrors += errors
totalSkipped += skipped
totalTests += tests
String subprojectStr = "${subproject.name}".padRight(titlePad)
String testStr = "tests: $tests".padRight(itemPad)
String skippedStr = "skipped: $skipped".padRight(itemPad)
String errorsStr = "errors: $errors".padRight(itemPad)
String failuresStr = "failures: $failures".padRight(itemPad)
logger.quiet("${subprojectStr}${separator}${testStr}${separator}${skippedStr}${separator}${errorsStr}${separator}${failuresStr}")
}
}
}
String title = "All Tests".padRight(titlePad)
String testStr = "tests: $totalTests".padRight(itemPad)
String skippedStr = "skipped: $totalSkipped".padRight(itemPad)
String errorsStr = "errors: $totalErrors".padRight(itemPad)
String failuresStr = "failures: $totalFailures".padRight(itemPad)
int itemsSize = [totalTests, totalSkipped, totalErrors, totalFailures].size()
logger.quiet("=" * ((itemPad * itemsSize) + titlePad + (separator.length() * itemsSize)))
logger.quiet("${title}${separator}${testStr}${separator}${skippedStr}${separator}${errorsStr}${separator}${failuresStr}")
}
}
subprojects { Project subproject ->
version project.projectVersion
ext {
userOrg = "grails"
isGrailsPlugin = false
isConfiguration = subproject.projectDir.parentFile.name == 'configurations'
isBuildSnapshot = version.toString().endsWith("-SNAPSHOT")
}
if (subproject.name == "configurations") {
return
}
if (isConfiguration) {
group "io.micronaut.configuration"
} else {
group projectGroupId
}
repositories {
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://repo.grails.org/grails/core" }
}
if (subproject.name.startsWith("examples")) {
// apply plugin:"org.grails.grails-web"
} else {
apply plugin: "groovy"
apply plugin: "java"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
compileJava.options.compilerArgs.add '-parameters'
compileTestJava.options.compilerArgs.add '-parameters'
if (
!subproject.name.startsWith('test-') &&
!subproject.toString().contains('build-projects')
) {
apply from: "${rootProject.rootDir}/gradle/publishing.gradle"
apply plugin: 'checkstyle'
checkstyle {
toolVersion = 8.10
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
// Per submodule
maxErrors = 5
maxWarnings = 10
showViolations = true
}
checkstyleTest.enabled = false
}
}
jar {
manifest {
attributes('Automatic-Module-Name': "${subproject.group}.${subproject.name}".replaceAll('[^\\w\\.\\$_]', "_"))
attributes('Implementation-Version': projectVersion)
attributes('Implementation-Title': 'Micronaut')
}
}
tasks.withType(Test) {
jvmArgs '-Duser.country=US'
jvmArgs '-Duser.language=en'
testLogging {
exceptionFormat = 'full'
}
afterSuite {
System.out.print(".")
System.out.flush()
}
reports.html.enabled = !System.getenv("TRAVIS")
reports.junitXml.enabled = !System.getenv("TRAVIS")
}
tasks.withType(Checkstyle) {
reports {
xml.enabled = !System.getenv("TRAVIS")
html.enabled = !System.getenv("TRAVIS")
}
}
configurations {
shadowCompile
shadowRuntime
documentation
all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
String group = details.requested.group
if (group == 'org.codehaus.groovy') {
details.useVersion(groovyVersion)
}
if (group == 'org.ow2.asm') {
details.useVersion(asmVersion)
}
}
}
}
def isDocumented = subproject.name != 'inject' && subproject.name != 'core' && subproject.name != 'aop' && !subproject.name.contains('asciidoc-config-props')
dependencies {
documentation "org.codehaus.groovy:groovy-templates:$groovyVersion"
documentation "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
if (subproject.name != "bom") {
compile dependencyVersion("slf4j")
}
if (isDocumented) {
compileOnly "io.micronaut.docs:micronaut-docs-asciidoc-config-props:$micronautDocsVersion"
}
compileOnly "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
testCompile "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
testCompile dependencyVersion("groovy")
testCompile(dependencyVersion("spock")) {
exclude module: 'groovy-all'
}
testCompile "cglib:cglib-nodep:2.2.2"
testCompile "org.objenesis:objenesis:1.4"
testRuntime "ch.qos.logback:logback-classic:1.2.3"
testCompile "org.codehaus.groovy:groovy-test:$groovyVersion"
compileOnly "org.ow2.asm:asm:$asmVersion"
compileOnly "org.ow2.asm:asm-commons:$asmVersion"
testCompile "org.ow2.asm:asm:$asmVersion"
testCompile "org.ow2.asm:asm-commons:$asmVersion"
}
task moveConfigProps() {
group 'documentation'
doLast {
ant.mkdir(dir: "${rootProject.buildDir}/config-props")
ant.move(file: "${subproject.buildDir}/classes/java/main/META-INF/config-properties.adoc", tofile: "${rootProject.buildDir}/config-props/${subproject.name}-config-properties.adoc", failonerror: false, quiet: true)
}
}
task javaDocAtReplacement(type: io.micronaut.docs.JavaDocAtValueReplacementTask, dependsOn: moveConfigProps) {
adocFile = new File("${rootProject.buildDir}/config-props/${subproject.name}-config-properties.adoc")
rootProjectDir = rootProject.projectDir
}
task replaceAtLink(dependsOn: moveConfigProps) {
group 'documentation'
doLast {
File file = new File("${rootProject.buildDir}/config-props/${subproject.name}-config-properties.adoc")
if (file.exists()) {
def atLinkReplacer = { String str ->
String newLine = str.substring(0, str.indexOf('{@link io.micronaut.'))
String sub = "api:" + str.substring(str.indexOf('{@link io.micronaut.') + '{@link io.micronaut.'.length())
newLine += sub.substring(0, sub.indexOf('}')) + '[]'
newLine += sub.substring(sub.indexOf('}') + '}'.length())
newLine
}
List<String> lines = file.readLines()
List<String> outputLines = []
for (String line : lines) {
String proccessedLine = line
while (proccessedLine.contains('{@link io.micronaut.')) {
proccessedLine = atLinkReplacer(proccessedLine)
}
outputLines << proccessedLine
}
file.text = outputLines.join('\n')
}
}
}
task processConfigProps(dependsOn: [replaceAtLink, javaDocAtReplacement]) {
group 'documentation'
ext {
individualConfigPropsFolder = "${rootProject.buildDir}/generated/configurationProperties"
}
doFirst {
if (!new File("${rootProject.buildDir}/generated").exists()) {
new File("${rootProject.buildDir}/generated").mkdir()
}
if (!new File("${rootProject.buildDir}/generated/configurationProperties").exists()) {
new File("${rootProject.buildDir}/generated/configurationProperties").mkdir()
}
}
doLast {
def f = new File("${rootProject.buildDir}/config-props/${subproject.name}-config-properties.adoc")
if (f.exists()) {
def lines = f.readLines()
def separator = "<<<"
List<String> accumulator = []
String configurationPropertyName = ''
for (String line : lines) {
if (line.startsWith('<a id="')) {
String sub = line.substring(line.indexOf('id="') + 'id="'.length())
sub = sub.substring(0, sub.indexOf('"'))
configurationPropertyName = sub
}
if (line == separator) {
File outputfile = new File("${individualConfigPropsFolder}/${configurationPropertyName}.adoc")
outputfile.createNewFile()
outputfile.text = accumulator.join('\n')
accumulator = []
configurationPropertyName = null
} else {
accumulator << line
}
}
}
}
}
groovydoc {
classpath += project.configurations.documentation
}
task allDeps(type: DependencyReportTask) {}
}
apply from: "gradle/docs.gradle"
// IDEA 2017.2 made a breaking change with IDE build output vs gradle build output
// [see https://youtrack.jetbrains.com/issue/IDEA-175172]
// the problem here is the gradle build uses <module-dir>/build/classes/main
// while IDEA uses <module-dir>/out/production/..
// As a result, compiling ast or java-inject module and using the IDEA test runner fails because the
// generated bean classes for injection are in <module-dir>/build, not <module-dir>/out
allprojects {
apply plugin: 'idea'
idea {
module {
outputDir file('build/classes/java/main')
testOutputDir file('build/classes/groovy/test')
}
}
apply from: rootProject.file('gradle/license.gradle')
}
sdkman {
api = "https://vendors.sdkman.io"
consumerKey = System.getenv("GVM_SDKVENDOR_KEY") ?: project.hasProperty("gvmSdkvendorKey") ? project.gvmSdkvendorKey : ''
consumerToken = System.getenv("GVM_SDKVENDOR_TOKEN") ?: project.hasProperty("gvmSdkvendorToken") ? project.gvmSdkvendorToken : ''
candidate = "micronaut"
version = project.version
url = "https://github.com/micronaut-projects/micronaut-core/releases/download/v${project.version}/micronaut-${project.version}.zip"
hashtag = "#micronautfw"
}
htmlSanityCheck {
sourceDir = new File("${rootProject.buildDir}/docs/")
sourceDocuments = ["index.html"]
}
docs.finalizedBy(htmlSanityCheck)