-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
311 lines (257 loc) · 9.54 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id 'java'
id 'idea'
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'nebula.release' version '16.0.0'
}
project.ext {
JUNIT_VERSION = '5.9.0'
JUNIT_MOCKSERVER_VERSION = '5.0.0-alpha.10'
}
/* PROJECT DEPENDENCY VERSIONS */
// define all common versioned dependencies here
project.ext.dependencyStrings = [
GOOGLE_GUICE: 'com.google.inject:guice:5.1.0',
TYPESAFE_CONFIG: 'com.typesafe:config:1.4.2',
ORG_YAML: 'org.yaml:snakeyaml:1.32',
OKHTTP: 'com.squareup.okhttp3:okhttp:4.10.0',
ELASTIC_APM: 'co.elastic.apm:apm-agent-api:1.34.0',
JANSI: 'org.fusesource.jansi:jansi:2.4.0',
PICOCLI: 'info.picocli:picocli:4.6.2'
]
/**
* Spark provided dependencies
* Can be used with compileOnly (from https://github.com/apache/spark/blob/master/pom.xml)
*/
project.ext.sparkDependencyStrings = [
JACKSON_CORE: 'com.fasterxml.jackson.core:jackson-core:2.14.0',
APACHE_COMMONS_TEXT: 'org.apache.commons:commons-text:1.10.0'
]
allprojects {
afterEvaluate { project ->
println "I'm configuring $project.name with version $project.version"
}
group = 'io.datatok'
}
subprojects {
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'nebula.release'
if (project.name == "djobi-cli") {
apply plugin: 'java'
} else {
apply plugin: 'java-library'
}
configurations.runtimeOnly.setCanBeResolved(true)
configurations.compileOnly.setCanBeResolved(true)
// https://remonsinnema.com/2016/05/09/how-to-manage-dependencies-in-a-gradle-multi-project-build/
configurations {
}
tasks {
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
}
ext.djobi = [
/**
* Create a task: "makeRelease"
* - called by djobiAssemble
*/
createRelease: {
String projectShortName = project.name.replace("djobi-", "")
String taskName = "makeRelease"
shadowJar.enabled = false
task(taskName, type: ShadowJar) {
doFirst {
println "Packaging ${project.name} "
}
from sourceSets.main.output
configurations = [project.configurations.djobiRelease]
archiveFileName = "${project.name}-${project.version}-all.jar"
relocate 'com.typesafe.config', 'my.typesafe.config'
relocate 'com.google.inject', 'my.google.inject'
relocate 'com.google.common', 'my.google.common'
relocate 'okhttp3', 'my.okhttp3'
relocate 'okio', 'my.okio'
/*
minimize {
exclude(
'org.elasticsearch:.*:.*',
'com.databricks:.*:.*'
)
}
*/
}
shadowJar.dependsOn(taskName)
},
/**
* Create a task: "{variant}MakeRelease"
* - called by djobiAssemble
*/
createReleaseWithVariants: { variants ->
String projectShortName = project.name.replace("djobi-", "")
//project.gradle.startParameter.excludedTaskNames.add('ShadowJar')
shadowJar.enabled = false
variants.each { variant ->
String taskName = "${variant.name}MakeRelease"
task(taskName, type: ShadowJar) {
doFirst {
println "Packaging variant ${project.name} / ${variant.name} "
}
classifier = "${variant.name}"
from sourceSets.main.output
configurations = [project.configurations."${variant.name}"]
archiveFileName = "${project.name}-${variant.name}-${project.version}-all.jar"
relocate 'com.typesafe.config', 'my.typesafe.config'
relocate 'com.google.inject', 'my.google.inject'
relocate 'com.google.common', 'my.google.common'
relocate 'okhttp3', 'my.okhttp3'
relocate 'okio', 'my.okio'
minimize {
exclude(dependency('org.elasticsearch:.*:.*'))
}
}
shadowJar.dependsOn(taskName)
}
}
];
task allDeps(type: DependencyReportTask) {}
repositories {
mavenCentral()
}
dependencies {
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "${JUNIT_VERSION}"
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: "${JUNIT_VERSION}"
testImplementation(
[group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "${JUNIT_VERSION}"],
[group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: "${JUNIT_VERSION}"],
[group: 'com.squareup.okhttp3', name: 'mockwebserver3-junit5', version: "${JUNIT_MOCKSERVER_VERSION}"]
)
}
sourceSets {
test {
compileClasspath += configurations.compileOnly
}
}
test {
if (System.getProperty("includeIntegrationTests") == null) {
useJUnitPlatform {
excludeTags("IntegrationTest", "NeedDocker")
}
}
environment "projectRoot", System.getProperty("user.dir")
environment "SPARK_LOCAL_IP", "127.0.0.1"
jvmArgs (
'-Dconfig.file=./src/test/resources/env.conf',
'-Dlog4j.configuration=log4j.properties',
'-Djunit.jupiter.extensions.autodetection.enabled=true',
'--add-opens=java.base/java.lang=ALL-UNNAMED',
'--add-opens=java.base/java.lang.invoke=ALL-UNNAMED',
'--add-opens=java.base/java.lang.reflect=ALL-UNNAMED',
'--add-opens=java.base/java.io=ALL-UNNAMED',
'--add-opens=java.base/java.net=ALL-UNNAMED',
'--add-opens=java.base/java.nio=ALL-UNNAMED',
'--add-opens=java.base/java.util=ALL-UNNAMED',
'--add-opens=java.base/java.util.concurrent=ALL-UNNAMED',
'--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED',
'--add-opens=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-opens=java.base/sun.nio.cs=ALL-UNNAMED',
'--add-opens=java.base/sun.security.action=ALL-UNNAMED',
'--add-opens=java.base/sun.util.calendar=ALL-UNNAMED',
'--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED'
)
testLogging {
exceptionFormat = "short"
debug {
events "started", "skipped", "failed"
exceptionFormat "short"
}
}
failFast = false
testLogging.showStandardStreams = true
maxParallelForks = 1
//reports.html.enabled = false
};
};
nebulaRelease {
releaseBranchPatterns = [/master/, /HEAD/, /(release(-|\/))?v?\d+\.\d+\.\d+/]
};
task djobiAssemble(type: Sync) {
doFirst {
file("$buildDir/release").delete()
}
doLast {
copy {
from 'djobi-core/build/manifest/djobi-core.properties'
into "$buildDir/release"
}
copy {
from 'djobi-cli/src/main/release'
filter { line -> line.replaceAll('%%VERSION%%', project.version.toString()) }
into "$buildDir/release"
fileMode = 0744
}
}
from(subprojects.findAll { (it.name != "djobi-tests") }.collect { it.tasks.withType(ShadowJar) }) {
include "**/*-all.jar"
into "libs"
rename '^(.+)-all.jar', '$1.jar'
}
into "$buildDir/release"
};
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
//
// Keep track of total failure count for later test and output
//
def testFailures = 0
//
// Every subproject should ignore test failures, but here we add a
// test suite failure filter to ensure we keep track of the fact that
// failures have occurred (for the build failure check below)
//
subprojects {
test {
ignoreFailures true
afterSuite { td, tr ->
if (td.getParent() == null) {
testFailures += tr.getFailedTestCount()
}
}
}
}
//
// The last thing to do in this task is to check for failures.
// The build as a whole should fail if any tests failed.
//
doLast {
if (testFailures > 0) {
throw new Exception("There were ${testFailures} test failures")
}
}
};
//
// Add the test report to the dependency tree for a standard build
//
build.dependsOn(testReport);
/**
* Relocate some common libs, to prevent conflicts.
*/
shadowJar {
relocate 'com.typesafe.config', 'io.datatok.djobi.typesafe.config'
relocate 'com.google.inject', 'io.datatok.djobi.google.inject'
relocate 'com.google.common', 'io.datatok.djobi.google.common'
relocate 'okhttp3', 'io.datatok.djobi.okhttp3'
relocate 'okio','io.datatok.djobi.okio'
minimize()
}
defaultTasks 'build'