-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
166 lines (148 loc) · 5.45 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
plugins {
id("groovy")
id("com.github.johnrengelman.shadow") version "7.1.0"
id("io.micronaut.application") version "2.0.8"
id("org.asciidoctor.jvm.convert") version "3.3.2"
id('jacoco')
id("com.gorylenko.gradle-git-properties") version "2.3.2"
id('net.thauvin.erik.gradle.semver') version '1.0.4'
}
shadowJar {
mergeServiceFiles()
}
group "au.org.biodiversity.nslapi"
ext {
micronautVersion = "3.1.4"
}
apply from: "gradle/asciidoc.gradle"
repositories {
mavenCentral()
}
micronaut {
testRuntime("spock2")
processing {
incremental(true)
annotations("au.org.biodiversity.nslapi.*")
}
}
dependencies {
// Micronaut
annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
annotationProcessor("io.micronaut:micronaut-inject-java")
compileOnly("io.micronaut:micronaut-inject-groovy")
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut.groovy:micronaut-runtime-groovy")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-management")
// Groovy
implementation('org.codehaus.groovy:groovy-all:3.0.9')
compileOnly("io.micronaut:micronaut-inject-groovy")
implementation("io.micronaut.groovy:micronaut-runtime-groovy")
compileOnly platform("io.micronaut:micronaut-bom:$micronautVersion")
// Data
compileOnly('org.codehaus.groovy:groovy-sql:3.0.9')
// implementation("io.micronaut.sql:micronaut-jdbc-tomcat")
runtimeOnly("org.postgresql:postgresql:42.2.13")
// http
implementation("io.micronaut:micronaut-http-client")
compileOnly("io.micronaut:micronaut-http-validation")
implementation("io.micronaut:micronaut-http-server-netty")
// Logging
runtimeOnly("ch.qos.logback:logback-classic")
implementation("org.codehaus.janino:janino:3.1.0")
// swagger
annotationProcessor("io.micronaut.openapi:micronaut-openapi:3.2.0")
compileOnly("io.micronaut.openapi:micronaut-openapi")
implementation("io.swagger.core.v3:swagger-annotations")
// testing
testImplementation "io.micronaut.test:micronaut-test-spock"
testImplementation("org.spockframework:spock-core") {
exclude group: "org.codehaus.groovy", module: "groovy-all"
}
}
application {
mainClass.set("au.org.biodiversity.nslapi.Application")
}
tasks.withType(GroovyCompile) {
groovyOptions.forkOptions.jvmArgs.add('-Dgroovy.parameters=true')
groovyOptions.forkOptions.jvmArgs.add('-Dmicronaut.openapi.views.spec=rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop')
}
run.classpath += configurations.developmentOnly
// Hot-Reloading
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs.addAll([
'-parameters',
// enables incremental compilation
'-Amicronaut.processing.incremental=true',
'-Amicronaut.processing.annotations=au.org.biodiversity.*',
"-Amicronaut.processing.group=$project.group",
"-Amicronaut.processing.module=$project.name",
])
}
run {
doFirst {
println "nslapi version: $version"
String originalFn = "build/classes/groovy/main/META-INF/swagger/nsl-api-0.0.1.yml"
String newFn = "build/classes/groovy/main/META-INF/swagger/nsl-api-${version}.yml"
String indexFn = "build/classes/groovy/main/META-INF/swagger/views/swagger-ui/index.html"
File swaggerFile = new File(originalFn)
File NewSwaggerFile = new File(newFn)
NewSwaggerFile.withWriter { w ->
swaggerFile.eachLine { l->
if (l.contains(' version: 0.0.1')) {
l = ' version: ' + version
println l
}
w << l + System.getProperty("line.separator")
}
}
Boolean deleted = swaggerFile.delete()
if (deleted) {
NewSwaggerFile.renameTo(newFn)
println "Done updating swagger version!!!"
} else {
println "FAILED to match swagger version with app version"
}
// Change index file
File indexFile = new File(indexFn)
indexFile.renameTo(indexFn + ".bak")
new File(indexFn).withWriter { w ->
new File(indexFn + ".bak").eachLine { line ->
w << line.replaceAll( '0.0.1', version) + System.getProperty("line.separator")
}
}
}
}
tasks.withType(JavaExec) {
classpath += configurations.developmentOnly
jvmArgs('-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
if (gradle.startParameter.continuous) {
systemProperties(
'micronaut.io.watch.restart':'true',
'micronaut.io.watch.enabled':'true',
"micronaut.io.watch.paths":"src/main"
)
}
}
java {
sourceCompatibility = JavaVersion.toVersion("11")
targetCompatibility = JavaVersion.toVersion("11")
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
//tasks.withType(Test) {
// dependsOn(setupTestDb)
//}
test.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote',
"-Dmicronaut.config.files=./src/test/resources/nsl-api-config.groovy",
"-Dmicronaut.environments=test")