-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
build.gradle
454 lines (386 loc) · 14.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
import java.util.concurrent.ConcurrentHashMap
description = "Apereo CAS Management Application $version"
defaultTasks "clean", "build"
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
classpath "com.gorylenko.gradle-git-properties:gradle-git-properties:$gradleGitVersion"
classpath "io.freefair.gradle:lombok-plugin:$gradleLombokVersion"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:$gradleErrorProneVersion"
classpath "com.github.node-gradle:gradle-node-plugin:$gradleNodeVersion"
classpath "io.github.gradle-nexus:publish-plugin:$gradleNexusPublishingVersion"
}
}
ext {
srcTagMap = new ConcurrentHashMap<File, Set<String>>()
sonatypeUsername = System.getProperty("sonatypeUsername")
sonatypePassword = System.getProperty("sonatypePassword")
publishSnapshots = Boolean.getBoolean("publishSnapshots")
publishReleases = Boolean.getBoolean("publishReleases")
skipBootifulArtifact = providers.systemProperty("skipBootifulArtifact").forUseAtConfigurationTime().present
skipErrorProneCompiler = providers.systemProperty("skipErrorProneCompiler").forUseAtConfigurationTime().present
enableRemoteDebugging = Boolean.getBoolean("enableRemoteDebugging")
remoteDebuggingSuspend = Boolean.getBoolean("remoteDebuggingSuspend") ? "y" : "n"
generateGitProperties = Boolean.getBoolean("generateGitProperties")
ci = System.getenv("CI") || Boolean.getBoolean("CI")
}
def isArtifactSigningRequired = {
return publishReleases
}
apply plugin: "io.github.gradle-nexus.publish-plugin"
nexusPublishing {
packageGroup = "org.apereo"
repositories {
sonatype {
stagingProfileId = "11d1ddbbdeae9d"
username = "${sonatypeUsername}"
password = "${sonatypePassword}"
}
}
clientTimeout = java.time.Duration.ofSeconds(120)
connectTimeout = java.time.Duration.ofSeconds(120)
transitionCheckOptions {
maxRetries.set(60)
delayBetween.set(java.time.Duration.ofMillis(60000))
}
}
apply from: rootProject.file("gradle/dependencies.gradle")
allprojects {
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: "java-library"
if (gradle.startParameter.taskNames.any {task -> task.equalsIgnoreCase("install") }) {
apply plugin: "maven"
}
apply from: rootProject.file("gradle/tasks.gradle")
if (rootProject.publishReleases || rootProject.publishSnapshots || rootProject.generateGitProperties) {
apply plugin: "com.gorylenko.gradle-git-properties"
gitProperties {
extProperty = "gitProps"
gitPropertiesName = "mgmt-git.properties"
keys = ["git.branch", "git.build.time", "git.build.user.name",
"git.build.version", "git.commit.id", "git.remote.origin.url"]
}
}
project.ext["forceBootifulArtifact"] = null
java {
toolchain {
languageVersion = JavaLanguageVersion.of(project.targetCompatibility)
}
}
idea {
module {
downloadSources = false
downloadJavadoc = false
jdkName = project.targetCompatibility
excludeDirs += file(".gradle")
[".settings", "classes", "bin", "out", "docs", "dependency-cache", "libs", "reports", "resources", "test-results", "tmp"].each {
excludeDirs += file("$buildDir/$it")
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "$sonatypeReleasesRepositoryUrl"
mavenContent { releasesOnly() }
}
maven {
url "https://build.shibboleth.net/maven/releases/"
mavenContent {releasesOnly() }
content {
includeGroupByRegex "org\\.opensaml.*"
includeGroupByRegex "net\\.shibboleth.*"
}
}
maven {
url "https://jitpack.io"
content {
includeGroupByRegex ".*wss4j.*"
}
mavenContent { releasesOnly() }
}
}
javadoc {
options.memberLevel = JavadocMemberLevel.PUBLIC
options.addBooleanOption('html5', true)
options.addStringOption('Xdoclint:html,reference,syntax', '-quiet')
options.addStringOption('encoding', 'UTF-8')
failOnError = providers.systemProperty("ignoreJavadocFailures").present
excludes = ['**/generated/**']
}
}
subprojects {
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 {}
}
if (projectShouldBePublished(project)) {
apply plugin: "maven-publish"
apply plugin: "signing"
}
if (!rootProject.skipErrorProneCompiler) {
apply plugin: "net.ltgt.errorprone"
}
ext.libraries = rootProject.ext.libraries
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://build.shibboleth.net/nexus/content/repositories/releases"
content {
includeGroupByRegex "org\\.opensaml.*"
includeGroupByRegex "net\\.shibboleth.*"
}
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
mavenContent { snapshotsOnly() }
}
maven {
url "https://oss.sonatype.org/content/repositories/releases"
mavenContent { releasesOnly() }
}
maven {
url "https://splunk.jfrog.io/splunk/ext-releases-local"
content {
includeGroupByRegex ".*splunk.*"
}
mavenContent { releasesOnly() }
}
maven {
url "https://repo.terracotta.org/maven2"
mavenContent { releasesOnly() }
content {
includeGroup "org.terracotta"
}
}
}
configurations {
tests
provided
}
apply from: rootProject.file("gradle/overrides.gradle")
/**
* Apply publishing rules after the build has had a chance to
* evaluate sub-projects to apply plugins, etc.
*/
afterEvaluate { project ->
if (projectShouldBePublished(project)) {
//logger.info "Project ${project.name} should be published"
apply from: rootProject.file("gradle/maven.gradle")
publishing {
publications {
def isWarPluginApplied = project.plugins.hasPlugin("war")
if (isWarPluginApplied) {
//logger.info "Project ${project.name} should be published as a WAR"
mavenWeb(MavenPublication) {
from components.web
pom {
createPom(it, project)
}
pom.withXml {
createPomRepositories(asNode())
}
}
} else if (project.hasProperty("skipPublication") && project.skipPublication) {
logger.info "Skipping artifact publication for project ${project.name}"
} else {
//logger.info "Project ${project.name} should be published as a JAR"
mavenJava(MavenPublication) {
from components.java
artifact tasks['sourcesJar']
artifact tasks['resourcesJar']
artifact tasks['javadocJar']
artifact tasks['testJar']
pom {
createPom(it, project)
}
pom.withXml {
createPomRepositories(asNode())
}
}
}
}
repositories {
if (rootProject.publishReleases) {
maven {
name "Sonatype-Releases"
url "${sonatypeRepositoryUrl}"
mavenContent {
releasesOnly()
}
credentials {
username "${sonatypeUsername}"
password "${sonatypePassword}"
}
}
}
if (rootProject.publishSnapshots) {
maven {
name "Sonatype-Snapshots"
url "${sonatypeSnapshotsRepositoryUrl}"
mavenContent {
snapshotsOnly()
}
credentials {
username "${sonatypeUsername}"
password "${sonatypePassword}"
}
}
}
}
}
signing {
required = isArtifactSigningRequired
sign publishing.publications
}
}
}
artifacts {
tests testJar
if (rootProject.publishReleases || rootProject.publishSnapshots) {
archives sourcesJar
archives javadocJar
archives resourcesJar
}
archives testJar
}
sourceSets {
main {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
java {
srcDirs = ["${projectDir}/src/main/java"]
}
resources {
srcDirs = ["${projectDir}/src/main/resources"]
}
}
test {
java {
srcDirs = ["${projectDir}/src/test/java"]
}
resources {
srcDirs = ["${projectDir}/src/test/resources"]
}
}
}
ext.buildDate = null
ext.buildJarFile = new File(project.buildDir, "libs/${project.name}-${project.version}.jar")
tasks.withType(JavaCompile).configureEach {
options.fork = true
options.incremental = true
def casCompilerArgs = ["-parameters"]
def terminateCompilerOnWarning = project.ext.properties.get("terminateCompilerOnWarning", true)
if (terminateCompilerOnWarning) {
casCompilerArgs.add("-Werror")
}
if (!rootProject.skipErrorProneCompiler) {
options.errorprone.allErrorsAsWarnings = false
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.errorproneArgs.addAll(['-Xep:SameNameButDifferent:OFF', '-Xep:ParameterName:OFF',
'-Xep:MissingOverride:OFF', '-Xep:MissingSummary:OFF',
'-Xep:JavaUtilDate:OFF', '-Xep:JdkObsolete:OFF'])
casCompilerArgs.add("-XDcompilePolicy=byfile")
}
options.compilerArgs.addAll(casCompilerArgs)
}
if (projectShouldBePublished(project)) {
apply plugin: "io.freefair.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": "${-> project.ext.has("gitProps") ? project.ext.gitProps['git.commit.id'] : 'N/A'}",
"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}"
}
}
dependencies {
implementation libraries.validationapi
api libraries.slf4j
api libraries.commons
api libraries.springboot
api libraries.javax
if (!skipErrorProneCompiler) {
errorprone "com.google.errorprone:error_prone_core:$errorProneVersion"
}
testImplementation libraries.tests
implementation libraries.log4j
}
}
tasks.withType(Javadoc) {
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") {
archiveClassifier = "javadoc"
from javadoc
}
task rootSourcesJar(type: Jar, description: "Build JAR for the root CAS module") {
archiveBaseName = "${project.archivesBaseName}"
from rootProject.file("src")
}
task gradleHome(description: "Display GRADLE_HOME environment variable") {
doFirst {
println "\nexport GRADLE_HOME=" + gradle.gradleHomeDir
}
}
if (rootProject.publishReleases || rootProject.publishSnapshots) {
artifacts {
archives aggregateJavadocsIntoJar
archives rootSourcesJar
}
}
task casVersion(description: "Display current CAS version") {
doLast {
println rootProject.version
}
}
task signingKey(description: "Display CAS signing key id") {
doLast {
println "Signing key: " + project.findProperty("signing.keyId")
}
}
task verifyRequiredJavaVersion {
def requiredVersion = JavaVersion.toVersion(project.targetCompatibility)
if (!JavaVersion.current().isCompatibleWith(requiredVersion)) {
throw new GradleException("Current Java version ${JavaVersion.current()} does not match required Java version ${requiredVersion}")
}
}
boolean projectShouldBePublished(Project project) {
return !["api", "core", "docs", "support", "webapp", "cas-server-documentation"].contains(project.name)
}