forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
551 lines (473 loc) · 18.8 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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
import java.util.concurrent.ConcurrentHashMap
description = "Apereo Central Authentication Service $version"
defaultTasks "clean", "build"
ext {
srcTagMap = new ConcurrentHashMap<File, Set<String>>()
sonatypeUsername = System.getProperty("sonatypeUsername")
sonatypePassword = System.getProperty("sonatypePassword")
publishSnapshots = Boolean.getBoolean("publishSnapshots")
publishReleases = Boolean.getBoolean("publishReleases")
if ((publishSnapshots || publishReleases) && (sonatypeUsername == null || sonatypePassword == null)) {
throw new GradleException("No credentials are configured to publish releases or snapshots")
}
testCategoryType = System.getProperty("testCategoryType")
skipBootifulArtifact = System.getProperty("skipBootifulArtifact")
skipErrorProneCompiler = System.getProperty("skipErrorProneCompiler")
forceBom = Boolean.getBoolean("forceBom")
enableRemoteDebugging = Boolean.getBoolean("enableRemoteDebugging")
remoteDebuggingSuspend = Boolean.getBoolean("remoteDebuggingSuspend") ? "y" : "n"
continuousIntegrationBuild = Boolean.getBoolean("CI") || Boolean.getBoolean("TRAVIS") || Boolean.getBoolean("CONTINUOUS_INTEGRATION")
/*
Open the project git repository in the current directory.
Get commit id of HEAD.
*/
git = org.ajoberstar.grgit.Grgit.open(dir: file('.').canonicalPath)
def gitHead = git.head()
currentRevision = gitHead.id
currentAbbreviatedRevision = gitHead.abbreviatedId
git.close()
}
def isArtifactSigningRequired = {
return publishReleases
}
apply from: rootProject.file("gradle/overrides.gradle")
apply from: rootProject.file("gradle/dependencies.gradle")
apply plugin: "com.github.ben-manes.versions"
if (project.ext.continuousIntegrationBuild) {
apply plugin: "com.gradle.build-scan"
}
if (!Boolean.getBoolean("skipSonarqube")) {
apply plugin: "org.sonarqube"
}
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://maven.eveoh.nl/content/repositories/releases" }
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.spring.io/plugins-release" }
maven { url "https://repo.spring.io/libs-milestone" }
}
dependencies {
classpath "com.gradle:build-scan-plugin:2.3"
classpath "gradle.plugin.com.ewerk.gradle.plugins:jaxb2-plugin:1.0.9"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
classpath "com.netflix.nebula:gradle-lint-plugin:$gradleLintVersion"
classpath "io.franzbecker:gradle-lombok:$gradleLombokVersion"
classpath "com.github.ben-manes:gradle-versions-plugin:$gradleDependencyVersionsVersion"
classpath "io.spring.gradle:propdeps-plugin:$gradlePropDepsVersion"
classpath "org.ajoberstar:grgit:$gradleGitVersion"
classpath "net.ltgt.gradle:gradle-errorprone-javacplugin-plugin:$gradleErrorProneVersion"
classpath "org.owasp:dependency-check-gradle:$gradleDependencyCheckVersion"
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:$gradleSpotbugsVersion"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:$gradleSonarqubeVersion"
classpath "net.rdrei.android.buildtimetracker:gradle-plugin:$gradleTimeTrackerVersion"
}
}
if (rootProject.continuousIntegrationBuild) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
apply plugin: "build-time-tracker"
buildtimetracker {
reporters {
summary {
ordered false
threshold 50
barstyle "unicode"
shortenTaskNames false
}
}
}
}
apply plugin: "org.owasp.dependencycheck"
dependencyCheck {
//logging.captureStandardOutput LogLevel.DEBUG
/*
* Specifies if the build should be failed if a CVSS score equal
* to or above a specified level is identified.
*/
failBuildOnCVSS = 8
skipTestGroups = true
skipConfigurations = ['jacocoAgent', 'jacocoAnt', 'optional', 'provided', 'providedCompile', 'providedRuntime',
'signatures', 'spotbugs','spotbugsPlugins', 'checkstyle', 'errorprone', 'errorproneJavac',
'annotationProcessor', 'archives', 'developmentOnly', 'compileOnly',
'tests', 'testRuntimeOnly', 'testRuntimeClasspath', 'testRuntime', 'testImplementation',
'testCompileOnly', 'testCompileClasspath', 'testCompile', 'testAnnotationProcessor' ,
'bootArchives', 'bootRunAnnotationProcessor' ]
cveValidForHours = 24
suppressionFile = file("$rootProject.projectDir/style/dependency-check-suppressions.xml")
analyzers {
assemblyEnabled = false
swiftEnabled = false
cocoapodsEnabled = false
nodeEnabled = false
nodeAuditEnabled = false
autoconfEnabled = false
cmakeEnabled = false
pathToDotnet = false
nuspecEnabled = false
rubygemsEnabled = false
pyPackageEnabled = false
pyDistributionEnabled = false
nexusEnabled = false
centralEnabled = false
bundleAuditEnabled = false
composerEnabled = false
opensslEnabled = false
archiveEnabled = false
}
}
allprojects {
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: "jacoco"
apply plugin: "java"
project.ext["forceBootifulArtifact"] = null
if (!rootProject.publishSnapshots && !Boolean.getBoolean("skipGradleLint")) {
apply plugin: "nebula.lint"
gradleLint.rules = ["dependency-parentheses", "dependency-tuple"]
}
jacoco {
toolVersion = "$gradleJacocoVersion"
}
idea {
module {
downloadSources = false
downloadJavadoc = false
excludeDirs << file(".gradle")
["classes", "bin", "docs", "dependency-cache", "libs", "reports", "resources", "test-results", "tmp"].each {
excludeDirs << file("$buildDir/$it")
}
}
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "https://repo.spring.io/libs-milestone" }
maven { url "$sonatypeReleasesRepositoryUrl" }
}
javadoc {
options.addBooleanOption('html5', true)
failOnError = Boolean.getBoolean("ignoreJavadocFailures")
excludes = ['**/generated/**']
}
}
subprojects {
task dependencyCheckAnalyze(type: org.owasp.dependencycheck.gradle.tasks.Analyze) {
/*
Disable analyze in cas-server-core-api and cas-server-core because
support and webapp sub-projects will include their dependencies transitively.
*/
enabled = !"${project.name}".contains("cas-server-core")
}
task allDependenciesInsight(type: DependencyInsightReportTask,
description: "Produce insight information for all dependencies") {
doLast {}
}
task allDependencies(type: DependencyReportTask,
description: "Display a graph of all project dependencies") {
doLast {}
}
apply plugin: "java-library"
if (!rootProject.skipErrorProneCompiler) {
apply plugin: "net.ltgt.errorprone-javacplugin"
}
apply plugin: "propdeps"
apply plugin: "propdeps-maven"
apply plugin: "propdeps-idea"
apply plugin: "propdeps-eclipse"
apply from: rootProject.file("gradle/tasks.gradle")
apply from: rootProject.file("gradle/tests.gradle")
if (projectShouldBePublished(project)) {
apply plugin: "maven-publish"
apply plugin: "signing"
apply from: rootProject.file("gradle/maven.gradle")
signing {
required = isArtifactSigningRequired
sign publishing.publications
}
//signArchives.enabled = rootProject.publishReleases || rootProject.publishSnapshots
}
ext.libraries = rootProject.ext.libraries
repositories {
mavenLocal()
mavenCentral()
maven { url "https://build.shibboleth.net/nexus/content/repositories/releases" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/repositories/releases" }
maven { url "https://repo.spring.io/plugins-release/" }
maven { url "https://repo.spring.io/milestone/" }
maven { url "https://repo.spring.io/snapshot/" }
maven { url "https://repo.spring.io/libs-milestone" }
maven { url "https://dl.bintray.com/uniconiam/maven" }
maven { url "https://jitpack.io" }
maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" }
jcenter()
}
configurations {
tests
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
configurations.all {
resolutionStrategy {
if (!Boolean.getBoolean("skipVersionConflict")) {
failOnVersionConflict()
}
preferProjectModules()
cacheDynamicVersionsFor 1, "days"
cacheChangingModulesFor 5, "days"
/**
* Required for all JRadius modules
*/
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == "gnu-getopt") {
details.useTarget group: "gnu.getopt", name: "java-getopt", version: details.requested.version
}
}
}
exclude(group: "cglib", module: "cglib")
exclude(group: "cglib", module: "cglib-full")
exclude(group: "org.slf4j", module: "slf4j-log4j12")
exclude(group: "org.slf4j", module: "slf4j-simple")
exclude(group: "org.apache.logging.log4j", module: "log4j-to-slf4j")
}
artifacts {
tests testJar
if (!rootProject.publishSnapshots) {
archives sourcesJar
archives javadocJar
archives resourcesJar
archives testJar
}
}
sourceSets {
main {
java {
srcDirs = ["${projectDir}/src/main/java", "${projectDir}/src/main/groovy"]
}
resources {
srcDirs = ["${projectDir}/src/main/resources"]
}
}
test {
java {
srcDirs = ["${projectDir}/src/test/java", "${projectDir}/src/test/groovy"]
}
resources {
srcDirs = ["${projectDir}/src/test/resources"]
}
}
}
ext.buildDate = null
ext.buildJarFile = new File(project.buildDir, "libs/${project.name}-${project.version}.jar")
[compileTestJava, compileJava].each {
it.options.fork = false
it.options.incremental = false
def casCompilerArgs = ["-parameters"]
if (!rootProject.skipErrorProneCompiler) {
it.options.errorprone.allErrorsAsWarnings = false
it.options.errorprone.disableWarningsInGeneratedCode = true
it.options.errorprone.errorproneArgs += ['-Xep:ParameterName:OFF', '-Xep:MissingOverride:OFF']
casCompilerArgs.add("-XDcompilePolicy=byfile")
casCompilerArgs.add("-Werror")
}
it.options.compilerArgs += casCompilerArgs
}
def currentTime = java.time.ZonedDateTime.now()
compileJava.doLast {
buildDate = currentTime
jar.manifest {
attributes("Implementation-Date": project.buildDate)
}
}
tasks.jar.onlyIf {
project.buildDate != null || !project.buildJarFile.exists()
}
if (projectShouldBePublished(project)) {
apply plugin: "io.franzbecker.gradle-lombok"
lombok {
version = "$lombokVersion"
}
}
jar {
manifest {
attributes(
"Automatic-Module-Name": project.name,
"Implementation-Title": project.name,
"Implementation-Vendor": project.group,
"Created-By": project.group,
"Specification-Version": rootProject.currentRevision,
"Implementation-Version": project.version)
}
}
if (!Boolean.getBoolean("skipCheckstyle") && projectShouldBePublished(project)) {
apply plugin: "checkstyle"
checkstyle {
configProperties = [
"checkstyle.suppressions.file": new File(rootDir, "style/checkstyle-suppressions.xml"),
"checkstyle.importcontrol.file": new File(rootDir, "style/import-control.xml")]
configFile = new File(rootDir, "style/checkstyle-rules.xml")
ignoreFailures false
showViolations true
toolVersion "${checkstyleVersion}"
}
}
if (!Boolean.getBoolean("skipFindbugs") && projectShouldBePublished(project)) {
apply plugin: "com.github.spotbugs"
apply from: rootProject.file("gradle/spotbugs.gradle")
spotbugs {
toolVersion = "${spotbugsVersion}"
sourceSets = [sourceSets.main]
ignoreFailures = true
reportsDir = file("$project.buildDir/findbugsReports")
effort = "max"
reportLevel = "low"
includeFilter = file("$rootProject.projectDir/style/findbugs-rules.xml")
excludeFilter = file("$rootProject.projectDir/style/findbugs-excludes.xml")
//jvmArgs = ["-Xms2g", "-Xmx4g"]
extraArgs = ["maxHeap 4000"]
}
[spotbugsMain, spotbugsTest].each {
it.reports {
xml.enabled = true
html.enabled = false
}
it.finalizedBy outputSpotbugsReports
}
}
dependencies {
implementation libraries.aspectj
implementation libraries.validationapi
api libraries.jaxb
api libraries.slf4j
api libraries.guava
api libraries.commons
api libraries.jodatime
api libraries.inspektr
api libraries.persondirectory
api libraries.spring
api libraries.jackson
api libraries.httpclient
api libraries.quartz
api libraries.hibernate
api libraries.groovy
api libraries.caffein
api libraries.springcloud
api libraries.springboot
api libraries.springsecurity
api libraries.javax
if (!Boolean.getBoolean("skipFindbugs") && projectShouldBePublished(project)) {
spotbugs libraries.findbugs
spotbugs configurations.spotbugsPlugins.dependencies
spotbugsPlugins libraries.findbugscontrib
spotbugsPlugins libraries.findbugssec
}
if (!Boolean.getBoolean("skipErrorProneCompiler")) {
errorprone "com.google.errorprone:error_prone_core:$errorProneVersion"
errorproneJavac "com.google.errorprone:javac:$errorproneJavacVersion"
}
testImplementation libraries.tests
testImplementation libraries.groovy
testImplementation libraries.log4j
compileOnly libraries.findbugsannotations
}
}
wrapper {
gradleVersion = project.gradleVersion
}
task javadoc(type: Javadoc, description: "Aggregate all Javadocs into a single directory", overwrite: true) {
source subprojects.collect { project -> project.sourceSets.main.allJava }
destinationDir = new File(buildDir, "javadoc")
classpath = files(subprojects.collect { project -> project.sourceSets.main.compileClasspath })
options.addBooleanOption('html5', true)
failOnError = Boolean.getBoolean("ignoreJavadocFailures")
}
task aggregateJavadocsIntoJar(type: Jar, dependsOn: javadoc, description: "Aggregate all Javadocs into a single directory") {
classifier = "javadoc"
from javadoc
}
task rootSourcesJar(type: Jar, description: "Build JAR for the root CAS module") {
baseName = "${project.archivesBaseName}"
from rootProject.file("src")
}
task gradleHome(description: "Display GRADLE_HOME environment variable") {
doFirst {
println "\nexport GRADLE_HOME=" + gradle.gradleHomeDir
}
}
artifacts {
archives aggregateJavadocsIntoJar
archives rootSourcesJar
}
def publishedProjects = subprojects.findAll { !it.path.contains(':docs') }
task jacocoMerge(type: JacocoMerge) {
publishedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
dependsOn tasks.withType(Test)
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
subprojects.each {
if (!it.path.contains(":docs")) {
it.tasks.withType(Test).each { task -> dependsOn(task) }
}
}
dependsOn jacocoMerge
additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(files(subprojects.sourceSets.main.output).collect {
fileTree(dir: it,
include: '**/*.class',
exclude: [
'**/**Configuration.class',
'**/shell/cli/**',
'**/shell/commands/**',
'**/**Configuration$**',
'**/**Controller**',
'**/**ConfigurationMetadataGenerator**',
'**/**Application.class',
'**/**Application$**',
'**/**WebflowConfigurer.class',
'**/**WebflowConfigurer$**',
'**/**Exception.class',
'**/**Banner.class',
'**/**Exception$**',
'**/**Properties.class',
'**/**Properties$**'
])
})
executionData jacocoMerge.destinationFile
reports {
html.enabled = false
xml.enabled = true
}
}
task casVersion(description: "Display current CAS version") {
doLast {
println project.version
}
}
task signingKey(description: "Display CAS signing key id") {
doLast {
println "Signing key: " + project.findProperty("signing.keyId")
}
}
task verifyRequiredJavaVersion {
// println "Checking current Java version ${JavaVersion.current()} for required Java version ${project.targetCompatibility}"
if (!JavaVersion.current().name.equalsIgnoreCase("${project.targetCompatibility}")) {
throw new GradleException("Current Java version ${JavaVersion.current()} does not match required Java version ${project.targetCompatibility}")
}
}
boolean projectShouldBePublished(Project project) {
return !["api", "core", "docs", "support", "webapp", "cas-server-documentation"].contains(project.name)
}