-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
321 lines (260 loc) · 10.6 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.owasp:dependency-check-gradle:5.2.2'
}
}
plugins {
// Supports functionality similar to Maven BOM.
// Helps to avoid re-declaring dependency version in each subproject.
// See https://github.com/spring-gradle-plugins/dependency-management-plugin
id "io.spring.dependency-management" version "1.0.5.RELEASE"
id "de.undercouch.download" version "3.4.3"
id "com.github.spotbugs" version "2.0.0" apply false
}
// To update Gradle wrapper use:
// gradlew wrapper --gradle-version 3.3 --distribution-type all
// To enable JavaDoc generation add Gradle property to command line:
// -PincludeJavaDocs
def includeJavaDocs = hasProperty("includeJavaDocs")
// Spotbugs
def enableSpotbugs = hasProperty("spotbugs") || Boolean.getBoolean("spotbugs") || Boolean.parseBoolean(System.getenv('SPOTBUGS'))
if (enableSpotbugs) {
println("Spotbugs is ENABLED")
}
// We don't want to apply plugins and build artifacts for non-leaf (grouping) projects.
// So we create a list of leaf projects and apply all java-related plugins on them only.
def leafProjects = subprojects.findAll { subproject ->
subproject.subprojects.empty
}
ext.leafProjects = leafProjects // Publish as external variable
// Default test categories
ext.categories = 'Unit'
configure(leafProjects) {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: "com.github.spotbugs" // Static analysis
apply plugin: 'io.spring.dependency-management'
apply plugin: 'signing'
compileJava.options.encoding = 'UTF-8'
// --- JAVA 11 version ---
sourceCompatibility = 11
targetCompatibility = 11
compileJava.options.compilerArgs += '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED'
//compileJava.options.compilerArgs += '--add-exports java.base/jdk.internal.misc=ALL-UNNAMED'
compileJava.options.compilerArgs += '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
compileJava.options.compilerArgs += '--add-exports=java.desktop/sun.swing=ALL-UNNAMED'
compileJava.options.compilerArgs += '--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED'
compileJava.options.compilerArgs += '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
//--add-exports <module>/<module>/<package>=<target-module>(,<target-module>)*
// Defines versions of dependencies to be used by subprojects
// https://github.com/spring-gradle-plugins/dependency-management-plugin#dependency-management-dsl
dependencyManagement {
dependencies {
dependency ('com.epam.deltix:thread-affinity:1.0.4')
dependency group: 'com.epam.deltix', name: 'dfp', version: dfpVersion
dependency group: 'com.epam.deltix', name: 'hd-date-time', version: hdTimeVersion
dependency 'org.apache.commons:commons-lang3:3.7'
dependency 'javax.mail:mail:1.4.7'
dependency 'com.google.code.findbugs:jsr305:3.0.2'
dependency 'com.google.code.findbugs:annotations:3.0.1'
dependency 'com.epam.deltix:containers:3.1.2'
// dependency 'org.mockito:mockito-core:1.10.19'
dependencySet (group: 'com.epam.deltix', version: gflogVersion) {
entry 'gflog-api'
entry 'gflog-core'
entry 'gflog-jul'
entry 'gflog-dcl'
entry 'gflog-slf4j'
}
// JMH
dependencySet(group: 'org.openjdk.jmh', version: '1.19') {
entry 'jmh-core'
entry 'jmh-generator-annprocess'
}
}
}
ext {
vendor = 'EPAM'
isReleaseVersion = !version.endsWith("SNAPSHOT")
}
java {
withJavadocJar()
withSourcesJar()
}
// archivesBaseName = 'timebase-commons' + project.path.replaceAll(':', '-')
repositories {
mavenCentral()
}
dependencies {
compileOnly 'com.google.code.findbugs:jsr305'
compileOnly 'com.google.code.findbugs:annotations'
testImplementation 'junit:junit:4.12'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.9.0'
}
spotbugs {
toolVersion = "3.1.12"
effort = "max"
reportLevel = "medium"
sourceSets = [sourceSets.main] // exclude tests
excludeFilter = rootProject.file('spotbugs-excludes.xml')
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
enabled = enableSpotbugs
reports {
xml.enabled = false
html.enabled = true
}
}
javadoc {
// Suppress javadoc warnings about unsafe code
options.addStringOption('XDignore.symbol.file', 'quiet')
}
processResources {
from sourceSets.main.java.srcDirs
exclude '**/*.java'
includeEmptyDirs = false
}
processTestResources {
from sourceSets.test.java.srcDirs
exclude '**/*.java'
includeEmptyDirs = false
}
jar {
manifest {
attributes 'Manifest-Version': "1.0",
'Created-By': vendor,
'Implementation-Vendor': vendor,
'Implementation-Version': archiveVersion
}
}
afterEvaluate {
// populate project classpath after evaluating
jar.manifest.attributes 'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' ')
}
// Contains current project jar and all required dependencies for that project
def allJarsPath = 'build/alljars'
task gatherProjectDependencies(type: Sync) {
description 'Copies all project runtime dependencies to ' + allJarsPath
from project.configurations.runtime
into allJarsPath
}
task gatherAllJarsWithDependencies(type: Copy, dependsOn: ['jar', gatherProjectDependencies]) {
group "build"
description 'Copies all project JAR and all it\'s runtime dependencies to ' + allJarsPath
from jar // Main produced JAR of the subproject
into allJarsPath
}
def allTestJarsPath = 'build/alltestjars'
task gatherProjectTestDependencies(type: Sync) {
description 'Copies all project test dependencies to ' + allTestJarsPath
from project.configurations.testCompile
into allTestJarsPath
}
task generateTestJar(type: Jar) {
description 'Generates JAR with test classes'
classifier 'tests'
from sourceSets.test.output
}
task gatherAllTestJarsWithDependencies(type: Copy, dependsOn: ['jar', generateTestJar, gatherProjectTestDependencies]) {
group "build"
description 'Copies all project JAR and all it\'s test dependencies to ' + allTestJarsPath
from jar // Main produced JAR of the subproject
from generateTestJar // JAR with test classes
into allTestJarsPath
}
task luminaryJar(type: Jar) {
classifier = 'luminary'
from("$projectDir/schema") {
include "*.json"
include "**/*.lux"
}
}
tasks.withType(Javadoc) {
// "Xdoclint:all,-reference" - disables fail on missing JavaDoc reference. TODO: Consider removing this.
// "-quiet" - skips warning messages (warnings still shown).
options.addStringOption('Xdoclint:all,-reference', '-quiet')
}
if (!includeJavaDocs) {
tasks.withType(Javadoc).all { enabled = false }
}
def rUser = findProperty('SONATYPE_NEXUS_USERNAME') ?: System.getenv('SONATYPE_NEXUS_USERNAME') ?: "FakeUser"
def rPass = findProperty('SONATYPE_NEXUS_PASSWORD') ?: System.getenv('SONATYPE_NEXUS_PASSWORD') ?: "FakePass"
publishing {
repositories {
maven {
url = findProperty('SONATYPE_REPOSITORY') ?: System.getenv('SONATYPE_REPOSITORY') ?: "FakeRepo"
credentials {
username rUser
password rPass
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = project.name
packaging = 'jar'
description = 'Timebase Common utilities and collections'
url = 'https://github.com/epam/TimeBaseCommons.git'
scm {
connection = 'scm:git:https://github.com/epam/TimeBaseCommons.git'
developerConnection = 'scm:git:https://github.com/epam/TimeBaseCommons.git'
url = 'https://github.com/epam/TimeBaseCommons.git'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'alex-karpovich'
name = 'Alexander Karpovich'
email = '[email protected]'
url = 'https://github.com/alex-karpovich'
organization = 'EPAM Systems'
organizationUrl = 'https://www.epam.com/'
}
}
}
}
}
}
signing {
def signingKey = findProperty('SIGNING_PRIVATE_KEY') ?: System.getenv('SIGNING_PRIVATE_KEY') ?: "FakeUser"
def signingPassword = findProperty('SIGNING_PASSWORD') ?: System.getenv('SIGNING_PASSWORD') ?: "FakePass"
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
required { isReleaseVersion }
}
// //tasks.test { enabled = false }
// test {
// useJUnit {
// setIncludeCategories categories.split(',').collect { "deltix.util.CommonsJUnitCategories\$${it}".toString() } as Set
// }
// }
}
allprojects {
// See http://jeremylong.github.io/DependencyCheck/dependency-check-gradle
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
// skipProjects = nonJavaProjects
failBuildOnCVSS = 7
suppressionFile = file("$rootDir/dependency-check-suppression-file.xml")
analyzers {
assemblyEnabled = false
}
}
}
//def testTasks = ext.leafProjects*.test
//
//task generateTestReport(type: TestReport) {
// group 'verification'
// reportOn testTasks
// destinationDir = file("$rootDir/build/reports/junit/html/all_reports_merged") // TODO: Pick better name for merged report
//}