-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
executable file
·327 lines (278 loc) · 9.28 KB
/
build.gradle
File metadata and controls
executable file
·327 lines (278 loc) · 9.28 KB
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
//----------------------------------------------------------------
//
// Gradle project core configuration
//
//----------------------------------------------------------------
// Setup gradle and its plugins
plugins {
// Setup gradle for java library builds
id 'java-library'
// // The one fat jar with dependencies (without shade)
// id "com.github.onslip.gradle-one-jar" version "1.0.5"
// Shadow plugin used to build the shade jar
id 'com.github.johnrengelman.shadow' version '2.0.4'
// jacoco code coverage for test
id 'jacoco'
}
// Dependency providers to fetch from
repositories {
// Use jcenter for resolving your dependencies.
google()
gradlePluginPortal()
mavenCentral()
// You can declare any other Maven/Ivy/file repository here.
}
//----------------------------------------------------------------
//
// Project versioning
//
//----------------------------------------------------------------
// The Project version
version = '4.1.1'
// Setup java compilation version
sourceCompatibility = 1.8
targetCompatibility = 1.8
//----------------------------------------------------------------
//
// JavaCommons-core integration
//
//----------------------------------------------------------------
// JavaCommons core compilation
task buildJavaCommonsCore(type: GradleBuild) {
buildFile = './JavaCommons-core/build.gradle'
tasks = ['jar','fatJar']
}
// JavaCommons dstack compilation
task buildJavaCommonsDStack(type: GradleBuild) {
buildFile = './JavaCommons-dstack/build.gradle'
tasks = ['jar','fatJar']
}
// JavaCommons servlet compilation
task buildJavaCommonsServlet(type: GradleBuild) {
buildFile = './JavaCommons-servlet/build.gradle'
tasks = ['jar','fatJar']
}
// JavaCommons module compilation
task buildJavaCommonsModule(type: GradleBuild) {
buildFile = './JavaCommons-module/build.gradle'
tasks = ['jar','fatJar']
}
// JavaCommons pdf compilation
task buildJavaCommonsPdf(type: GradleBuild) {
buildFile = './JavaCommons-pdf/build.gradle'
tasks = ['jar','fatJar']
}
// Dependency linkage of core project build
compileJava {
dependsOn buildJavaCommonsCore
dependsOn buildJavaCommonsDStack
dependsOn buildJavaCommonsServlet
dependsOn buildJavaCommonsModule
}
//----------------------------------------------------------------
//
// Project dependencies
//
//----------------------------------------------------------------
// Dependencies used in the build
dependencies {
// JavaCommons dependencies
//-------------------------------------------------------------------------------------------------------------------
compile fileTree(dir: './JavaCommons-core/build/libs', include: ['*-nodep.jar'])
compile fileTree(dir: './JavaCommons-dstack/build/libs', include: ['*-nodep.jar'])
compile fileTree(dir: './JavaCommons-servlet/build/libs', include: ['*-nodep.jar'])
compile fileTree(dir: './JavaCommons-module/build/libs', include: ['*-nodep.jar'])
// These dependencies are exported as part of the "all" package
//-------------------------------------------------------------------------------------------------------------------
api fileTree(dir: './JavaCommons-core/build/libs', include: ['*-all.jar'])
api fileTree(dir: './JavaCommons-dstack/build/libs', include: ['*-all.jar'])
api fileTree(dir: './JavaCommons-servlet/build/libs', include: ['*-all.jar'])
api fileTree(dir: './JavaCommons-module/build/libs', include: ['*-all.jar'])
// This dependencies is used internally, and not exposed to consumers on their own compile classpath.
//-------------------------------------------------------------------------------------------------------------------
// implementation 'com.google.guava:guava:23.0'
// Testing dependencies
//-------------------------------------------------------------------------------------------------------------------
testImplementation 'junit:junit:4.12'
testImplementation 'com.carrotsearch:junit-benchmarks:0.7.2'
}
//----------------------------------------------------------------
//
// Jar build steps
//
//----------------------------------------------------------------
//
// Base JAR build settings
//
// `gradle jar`
//
jar {
// Archive name overwrite
archiveName = project.name+"-"+project.version+"-nodep"+".jar"
description = "Build the "+archiveName+" with no dependencies"
// Inherit the main jar manifest
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version
)
}
// Include the compile class files
from("./JavaCommons-core/build/classes/java/main") {
include "**/*"
}
from("./JavaCommons-dstack/build/classes/java/main") {
include "**/*"
}
from("./JavaCommons-servlet/build/classes/java/main") {
include "**/*"
}
from("./JavaCommons-module/build/classes/java/main") {
include "**/*"
}
}
//
// Shadow jar - dependencies are shaded
//
// `gradle shadowJar`
//
shadowJar {
// Archive name overwrite
archiveName = project.name+"-"+project.version+"-shade"+".jar"
description = "Build the "+archiveName+" with all dependencies shaded"
// Inherit the main jar manifest
manifest {
inheritFrom project.tasks.jar.manifest
}
// Shade depencies under "picoded.shade"
relocate "picoded", "picoded"
relocate "org", "picoded.shade.org"
relocate "com", "picoded.shade.com"
relocate "oracle", "picoded.shade.oracle"
}
//
// Fat jar - dependencies are included, and not shaded
//
// `gradle shadowJar`
//
task fatJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
// Archive name overwrite
archiveName = project.name+"-"+project.version+"-all"+".jar"
description = "Build the "+archiveName+" with all dependencies"
//
// Note that the following is extended heavily from the default setup of shadowJar task
// See : https://github.com/johnrengelman/shadow/blob/7ef6fc2699627f172b05a3bd3523201d63bb588f/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L38-L63
//
// NOTE : I dunno what this is - but it was setup in the default config
conventionMapping.with {
map('classifier') {
'all'
}
}
// Build from the main output
from sourceSets.main.output
// Load default configurations
configurations = [project.configurations.findByName('runtimeClasspath') ? project.configurations.runtimeClasspath : project.configurations.runtime]
// Inherit the main jar manifest
manifest {
inheritFrom project.tasks.jar.manifest
}
// Project dependencies libraries
doFirst {
def files = project.configurations.findByName(com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin.CONFIGURATION_NAME).files
if (files) {
def libs = [project.tasks.jar.manifest.attributes.get('Class-Path')]
libs.addAll files.collect { "${it.name}" }
manifest.attributes 'Class-Path': libs.findAll { it }.join(' ')
}
}
// Exclude signed jar signatures?
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA')
// Disable relocation
relocate "picoded", "picoded"
relocate "org", "org"
relocate "com", "com"
relocate "oracle", "oracle"
}
// Define the equivalent of buildAll
// for the build process done by "gradle build"
artifacts {
archives fatJar
archives shadowJar
archives jar
}
//----------------------------------------------------------------
//
// Concurent test threads
//
//----------------------------------------------------------------
test {
// Exclude performance related test
exclude "**/perf/*.java"
exclude "**/*_perf*"
// Include mssql, mysql, and oracle test only if they are configured respectively
//
// You can enable any of them by running the `gradle test` command with their `-P`
// option, for example `gradle test -Ptest_mssql`
if(!project.hasProperty("test_mssql")) {
exclude "**/*Mssql*"
}
if(!project.hasProperty("test_oracle")) {
exclude "**/*Oracle*"
}
if(!project.hasProperty("test_mysql")) {
exclude "**/*Mysql*"
}
if(!project.hasProperty("test_postgres")) {
exclude "**/*Postgres*"
}
if(!project.hasProperty("test_sqlite")) {
exclude "**/*Sqlite*"
}
// Setup test to run on parllel threads = to number of processors by default
if (project.hasProperty('maxParallelForks')) {
maxParallelForks = project.maxParallelForks as int
} else {
// As our test tends to be io-blocked rather then cpu
// we will run more tests in parallels
maxParallelForks = (Runtime.runtime.availableProcessors() * 2) as int
}
// Set up the number of tests per fork
if (project.hasProperty('forkEvery')) {
forkEvery = project.forkEvery as int
}
}
//----------------------------------------------------------------
//
// Jacoco test coverage
//
//----------------------------------------------------------------
jacoco {
toolVersion = "0.8.0"
}
// jacocoTestReport {
// // Build the report
// reports {
// xml.enabled true
// csv.enabled true
// // Report format compatible with codeconv.io
// xml.destination file("${buildDir}/reports/jacoco/report.xml")
// csv.destination file("${buildDir}/reports/jacoco/report.csv")
// }
// }
//----------------------------------------------------------------
//
// Quick multibuild steps
//
//----------------------------------------------------------------
task buildAll {
description = "Build all 3 jars: jar, shadowJar, fatJar"
dependsOn jar
dependsOn shadowJar
dependsOn fatJar
}
task testAndBuildAll {
description = "Performs the full test suite, then build all 3 jars: jar, shadowJar, fatJar"
dependsOn jacocoTestReport
dependsOn buildAll
}