/
build.gradle
348 lines (300 loc) · 12.2 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
import org.apache.tools.ant.filters.ReplaceTokens
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'com.github.spotbugs' version '5.0.6' apply false
id "io.freefair.lombok" version "6.4.3" apply false
id 'org.owasp.dependencycheck' version '6.5.3' apply false
}
ext {
interlokCoreVersion = project.findProperty('interlokCoreVersion') ?: '4.5-SNAPSHOT'
releaseVersion = project.findProperty('releaseVersion') ?: '4.5-SNAPSHOT'
nexusBaseUrl = project.findProperty('nexusBaseUrl') ?: 'https://nexus.adaptris.net/nexus'
mavenPublishUrl = project.findProperty('mavenPublishUrl') ?: nexusBaseUrl + '/content/repositories/snapshots'
javadocsBaseUrl = nexusBaseUrl + "/content/sites/javadocs/com/adaptris"
repoUsername = project.findProperty('repoUsername') ?: 'unknown'
repoPassword = project.findProperty('repoPassword') ?: 'unknown'
defaultNexusRepo = project.findProperty('defaultNexusRepo') ?: 'unknown'
interlokJavadocs= project.findProperty('interlokJavadocs') ?: javadocsBaseUrl + "/interlok-core/" + interlokCoreVersion
interlokCommonJavadocs= project.findProperty('interlokCommonJavadocs') ?: javadocsBaseUrl + "/interlok-common/" + interlokCoreVersion
offlineJavadocPackageDir = new File(project.buildDir, "offline-javadoc-packages")
organizationName = "Adaptris Ltd"
slf4jVersion = '1.7.36'
mockitoVersion = '4.4.0'
}
ext.hostname = { ->
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
return System.getenv("COMPUTERNAME")
}
return System.getenv("HOSTNAME")
}
ext.hasGraphViz = { ->
def app = "dot"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
app = app + ".exe"
}
return System.getenv("PATH").split(File.pathSeparator).any{
java.nio.file.Paths.get("${it}").resolve(app).toFile().exists()
}
}
ext.gitBranchNameOrTimestamp = { branchName ->
if (branchName.equals("HEAD") || branchName.equals("develop") || branchName.startsWith("release")) {
return new Date().format('HH:mm:ss z');
}
return branchName;
}
ext.buildInfo = { ->
new ByteArrayOutputStream().withStream { os ->
exec {
executable = "git"
args = ["rev-parse", "--abbrev-ref", "HEAD"]
standardOutput = os
}
def branchName = os.toString().replaceAll("\r", "").replaceAll("\n", "").trim();
return gitBranchNameOrTimestamp(branchName);
}
}
def propertyTemplate(dir, filename) {
def file = new File(dir, filename + "." + hostname())
if (file.exists()) {
return file.getName()
}
return filename
}
task clean(type: Delete) {
delete project.buildDir
}
allprojects {
tasks.withType(Jar) {
metaInf {
from ("$rootDir") {
include 'LICENSE*'
include 'NOTICE*'
}
}
}
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
}
subprojects {
// Apply the java plugin to add support for Java
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: "jacoco"
apply plugin: "io.freefair.lombok"
apply plugin: 'com.github.spotbugs'
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'project-report'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
group = 'com.adaptris'
version = releaseVersion
def versionDir = "$buildDir/version"
lombok.disableConfig = true
repositories {
mavenCentral()
if (defaultNexusRepo != "unknown") {
maven {
url "$defaultNexusRepo"
allowInsecureProtocol true
}
}
maven { url "$nexusBaseUrl/content/groups/public" }
maven { url "$nexusBaseUrl/content/groups/interlok" }
}
configurations {
javadoc {}
umlDoclet {}
offlineJavadocPackages {}
all*.exclude group: 'c3p0'
all*.exclude group: 'commons-logging'
all*.exclude group: 'javamail'
all*.exclude group: 'javax.mail', module: 'mail'
all*.exclude group: 'org.glassfish.hk2.external'
all*.exclude group: 'xalan', module: 'xalan'
all*.exclude group: 'net.sf.saxon', module: 'saxon'
all*.exclude group: 'org.codehaus.woodstox'
all*.exclude group: 'org.eclipse.jetty.orbit', module: 'javax.mail.glassfish'
// INTERLOK-3197 exclude old javax.mail
all*.exclude group: 'com.sun.mail', module: 'javax.mail'
all*.exclude group: 'javax.validation', module: 'validation-api'
all*.exclude group: 'javax.activation', module: 'activation'
all*.exclude group: 'javax.activation', module: 'javax.activation-api'
// INTERLOK-3740 switch from jcraft to com.github.mwiede jsch fork.
all*.exclude group: 'com.jcraft', module: 'jsch'
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
api ("com.adaptris:interlok-core:$interlokCoreVersion") { changing= true}
api ("com.adaptris:interlok-core-apt:$interlokCoreVersion") { changing= true}
implementation ("org.slf4j:slf4j-api:$slf4jVersion")
annotationProcessor ("com.adaptris:interlok-core-apt:$interlokCoreVersion") { changing= true}
testImplementation ('junit:junit:4.13.2')
testImplementation ("org.slf4j:slf4j-simple:$slf4jVersion")
testImplementation ("com.adaptris:interlok-stubs:$interlokCoreVersion") { changing= true }
testImplementation ("org.slf4j:slf4j-log4j12:$slf4jVersion")
testImplementation ("org.slf4j:jcl-over-slf4j:$slf4jVersion")
testImplementation ("org.mockito:mockito-core:$mockitoVersion")
testImplementation ("org.mockito:mockito-inline:$mockitoVersion")
javadoc("com.adaptris:interlok-core-apt:$interlokCoreVersion") { changing= true}
umlDoclet("nl.talsmasoftware:umldoclet:1.1.4")
offlineJavadocPackages ("com.adaptris:interlok-core:$interlokCoreVersion:javadoc@jar") { changing= true}
offlineJavadocPackages ("com.adaptris:interlok-common:$interlokCoreVersion:javadoc@jar") { changing= true}
}
javadoc {
onlyIf {
!hasGraphViz()
}
configure(options) {
options.linksOffline(interlokJavadocs, offlineJavadocPackageDir.getCanonicalPath() + "/interlok-core-$interlokCoreVersion-javadoc.jar")
options.linksOffline(interlokCommonJavadocs, offlineJavadocPackageDir.getCanonicalPath() + "/interlok-common-$interlokCoreVersion-javadoc.jar")
taglets = ["com.adaptris.taglet.ConfigTaglet", "com.adaptris.taglet.LicenseTaglet"]
options.addStringOption "tagletpath", configurations.javadoc.asPath
options.addStringOption('Xdoclint:none', '-quiet')
options.addBooleanOption "-no-module-directories", true
}
}
task umlJavadoc(type: Javadoc) {
group 'Documentation'
description 'Build javadocs using plantuml + graphviz + umldoclet, if dot is available'
onlyIf {
hasGraphViz()
}
// Since we are using lombok, we have to switch the source.
// c.f. https://github.com/freefair/gradle-plugins/issues/132
// source = sourceSets.main.allJava
source = sourceSets.main.extensions.delombokTask
classpath = project.sourceSets.main.compileClasspath
configure(options) {
options.linksOffline(interlokJavadocs, offlineJavadocPackageDir.getCanonicalPath() + "/interlok-core-$interlokCoreVersion-javadoc.jar")
options.linksOffline(interlokCommonJavadocs, offlineJavadocPackageDir.getCanonicalPath() + "/interlok-common-$interlokCoreVersion-javadoc.jar")
taglets = ["com.adaptris.taglet.ConfigTaglet", "com.adaptris.taglet.LicenseTaglet"]
options.addStringOption "tagletpath", configurations.javadoc.asPath
options.addStringOption('Xdoclint:none', '-quiet')
options.addBooleanOption "-no-module-directories", true
options.docletpath = configurations.umlDoclet.files.asType(List)
options.doclet = "nl.talsmasoftware.umldoclet.UMLDoclet"
options.addStringOption "umlBasePath", destinationDir.getCanonicalPath()
options.addStringOption "umlImageFormat", "SVG"
options.addStringOption "umlExcludedReferences", "java.lang.Exception,java.lang.Object,java.lang.Enum"
options.addStringOption "umlIncludePrivateClasses","false"
options.addStringOption "umlIncludePackagePrivateClasses","false"
options.addStringOption "umlIncludeProtectedClasses","false"
options.addStringOption "umlIncludeAbstractSuperclassMethods","false"
options.addStringOption "umlIncludeConstructors","false"
options.addStringOption "umlIncludePublicFields","false"
options.addStringOption "umlIncludePackagePrivateFields","false"
options.addStringOption "umlIncludeProtectedFields", "false"
options.addStringOption "umlIncludeDeprecatedClasses", "false"
options.addStringOption "umlIncludePrivateInnerClasses", "false"
options.addStringOption "umlIncludePackagePrivateInnerClasses", "false"
options.addStringOption "umlIncludeProtectedInnerClasses","false"
}
}
jacocoTestReport {
reports {
xml.required= true
html.required= true
}
}
sourceSets {
main {
output.dir(versionDir, builtBy: 'generateVersion')
}
}
// Generate the META-INF/adaptris-version file
task generateVersion {
doLast {
def versionFile = new File(new File(versionDir, 'META-INF'), 'adaptris-version')
versionFile.getParentFile().mkdirs()
ant.propertyfile(file: versionFile) {
entry(key: 'component.name', value: componentName)
entry(key: 'component.description', value: componentDesc)
entry(key: 'build.version', value: releaseVersion)
entry(key: 'groupId', value: project.group)
entry(key: 'artifactId', value: project.name)
entry(key: 'build.date', value: new Date().format('yyyy-MM-dd'))
entry(key: 'build.info', value: buildInfo())
}
}
}
task offlinePackageList(type: Copy) {
description 'Build an offline package-list for javadocs'
group 'Documentation'
project.configurations.offlineJavadocPackages.collect { dependency ->
from(zipTree(dependency)) {
into dependency.name
}
}
include "package-list"
include "element-list"
into offlineJavadocPackageDir
}
ext.hasGraphViz = { ->
return false
}
ext.testResourcesDir = { ->
return "${project.projectDir}/src/test/resources".replaceAll("\\\\", "/")
}
task generateUnitTestProperties {
doLast {
ant.property(file: project.projectDir.getCanonicalPath() + "/" + "build.properties")
ant.property(file: testResourcesDir() + "/" + propertyTemplate(testResourcesDir(), "unit-tests.properties.template"))
ant.echoproperties(destfile: testResourcesDir() + '/unit-tests.properties.resolved', prefix: "junit.")
ant.replace(file: testResourcesDir() + '/unit-tests.properties.resolved', token:"junit.", value: "")
}
}
task copyUnitTestProperties() {
dependsOn(generateUnitTestProperties)
doLast {
delete file( testResourcesDir() + '/unit-tests.properties')
ant.copy(file: testResourcesDir() + "/unit-tests.properties.resolved",
tofile: testResourcesDir() + '/unit-tests.properties') {
filterset {
filter(token: "JAVA_HOME", value: System.getProperty("java.home").replaceAll("\\\\", "/"))
filter(token: "BASE_DIR", value: project.projectDir.getCanonicalPath().replaceAll("\\\\", "/"))
filter(token: "BUILD_DIR", value: project.buildDir.getCanonicalPath().replaceAll("\\\\", "/"))
}
}
}
}
spotbugsMain {
effort = "max"
reportLevel = "high"
reports {
xml {
required.set(false)
}
html {
required.set(true)
stylesheet = 'default.xsl'
}
}
}
dependencyCheck {
suppressionFiles= [ "https://raw.githubusercontent.com/adaptris/interlok/develop/gradle/owasp-exclude.xml", "$rootDir/gradle/owasp-exclude.xml" ]
scanConfigurations = [ "api", "compileClasspath", "runtimeClasspath" ]
formats = [ "HTML", "JUNIT" ]
junitFailOnCVSS = 7.0
failBuildOnCVSS = 7.0
analyzers {
assemblyEnabled=false
}
}
// disable spotbugsTests which checks our test code..
spotbugsTest.enabled = false
task lgtmCompile(type: JavaCompile, dependsOn: delombok) {
group 'Build'
description 'Compile for lgtm'
source = sourceSets.main.extensions.delombokTask
destinationDirectory= sourceSets.main.java.classesDirectory
classpath = project.sourceSets.main.compileClasspath
}
lombok {
version = "1.18.22"
}
check.dependsOn jacocoTestReport
javadoc.dependsOn offlinePackageList, umlJavadoc
}