-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.gradle
285 lines (255 loc) · 9.77 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
import org.apache.tools.ant.taskdefs.condition.*
import org.gradle.internal.logging.text.*
import org.apereo.cas.metadata.*
import java.nio.file.*
import java.lang.reflect.*
import org.gradle.internal.logging.text.*
import static org.gradle.internal.logging.text.StyledTextOutput.Style
buildscript {
repositories {
if (project.privateRepoUrl) {
maven {
url project.privateRepoUrl
credentials {
username = project.privateRepoUsername
password = System.env.PRIVATE_REPO_TOKEN
}
}
}
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven {
url "https://repo.spring.io/milestone"
mavenContent { releasesOnly() }
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.springBootVersion}"
classpath "io.freefair.gradle:maven-plugin:${project.gradleFreeFairPluginVersion}"
classpath "io.freefair.gradle:lombok-plugin:${project.gradleFreeFairPluginVersion}"
classpath "com.google.cloud.tools:jib-gradle-plugin:${project.jibVersion}"
classpath "com.bmuschko:gradle-docker-plugin:${project.gradleDockerPluginVersion}"
}
}
repositories {
if (project.privateRepoUrl) {
maven {
url project.privateRepoUrl
credentials {
username = project.privateRepoUsername
password = System.env.PRIVATE_REPO_TOKEN
}
}
}
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/releases' }
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
mavenContent { snapshotsOnly() }
}
maven {
url "https://repository.apache.org/content/repositories/snapshots"
mavenContent { snapshotsOnly() }
}
maven {
url 'https://build.shibboleth.net/nexus/content/repositories/releases/'
mavenContent { releasesOnly() }
}
maven {
url "https://build.shibboleth.net/nexus/content/repositories/snapshots"
mavenContent { snapshotsOnly() }
}
maven {
url "https://repo.spring.io/milestone"
mavenContent { releasesOnly() }
}
}
apply plugin: "io.freefair.war-overlay"
apply plugin: "war"
apply plugin: "org.springframework.boot"
apply plugin: "io.freefair.lombok"
apply from: rootProject.file("gradle/springboot.gradle")
apply plugin: "com.google.cloud.tools.jib"
apply plugin: "com.bmuschko.docker-remote-api"
apply from: rootProject.file("gradle/tasks.gradle")
def out = services.get(StyledTextOutputFactory).create("cas")
configurations {
all {
resolutionStrategy {
cacheChangingModulesFor 0, "seconds"
cacheDynamicVersionsFor 0, "seconds"
preferProjectModules()
def failIfConflict = project.hasProperty("failOnVersionConflict") && Boolean.valueOf(project.getProperty("failOnVersionConflict"))
if (failIfConflict) {
failOnVersionConflict()
}
if (project.hasProperty("tomcatVersion")) {
eachDependency { DependencyResolveDetails dependency ->
def requested = dependency.requested
if (requested.group.startsWith("org.apache.tomcat") && requested.name != "jakartaee-migration") {
dependency.useVersion("${tomcatVersion}")
}
}
}
}
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.slf4j", module: "jcl-over-slf4j")
exclude(group: "org.apache.logging.log4j", module: "log4j-to-slf4j")
}
}
war {
entryCompression = ZipEntryCompression.STORED
enabled = false
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(project.targetCompatibility)
def chosenJvmVendor = null
JvmVendorSpec.declaredFields.each { field ->
if (field.type == JvmVendorSpec && Modifier.isStatic(field.getModifiers())) {
if (field.name == project.jvmVendor?.toUpperCase()) {
chosenJvmVendor = field.get(null)
return
}
}
}
if (chosenJvmVendor != null) {
vendor = chosenJvmVendor
out.withStyle(Style.Success).println("Using ${chosenJvmVendor} as the JVM vendor for the Java toolchain")
} else {
out.withStyle(Style.Info).println("JVM vendor ${project.jvmVendor} is not recognized")
}
}
}
bootBuildImage {
imageName = "${project.'containerImageOrg'}/${project.'containerImageName'}:${project.version}"
}
['jibDockerBuild', 'jibBuildTar', 'jib'].each { taskName ->
if (gradle.gradleVersion >= "8.0") {
getTasksByName(taskName, true).each(it -> {
it.notCompatibleWithConfigurationCache("Jib is not compatible with configuration cache");
it.enabled = !gradle.startParameter.isConfigurationCacheRequested()
})
}
}
def imagePlatforms = project.dockerImagePlatform.split(",")
def dockerUsername = providers.systemProperty("dockerUsername").getOrNull()
def dockerPassword = providers.systemProperty("dockerPassword").getOrNull()
def imageTagPostFix = providers.systemProperty("dockerImageTagPostfix").getOrElse("")
jib {
if (gradle.gradleVersion >= "8.0" && gradle.startParameter.isConfigurationCacheRequested()) {
out.withStyle(Style.Info).println("You are seeing this message because the Gradle configuration cache is turned on")
out.withStyle(Style.Info).println("Running Jib tasks to produce Docker images will require the command-line option: --no-configuration-cache")
out.withStyle(Style.Info).println("Jib does not support the Gradle configuration cache; Please see https://github.com/GoogleContainerTools/jib/issues/3132")
out.withStyle(Style.Info).println("Jib tasks are disabled.")
}
from {
image = project.baseDockerImage
platforms {
imagePlatforms.each {
def given = it.split(":")
platform {
architecture = given[0]
os = given[1]
}
}
}
}
to {
image = "${project.'containerImageOrg'}/${project.'containerImageName'}:${project.version}"
/**
ecr-login: Amazon Elastic Container Registry (ECR)
gcr: Google Container Registry (GCR)
osxkeychain: Docker Hub
*/
credHelper = "osxkeychain"
if (dockerUsername != null && dockerPassword != null) {
auth {
username = "${dockerUsername}"
password = "${dockerPassword}"
}
}
tags = [project.version]
}
container {
creationTime = "USE_CURRENT_TIMESTAMP"
entrypoint = ['/docker/entrypoint.sh']
ports = ['80', '443', '8080', '8443', '8444', '8761', '8888', '5000']
labels = [version:project.version, name:project.name, group:project.group, org:project.containerImageOrg]
workingDirectory = '/docker/cas/war'
}
extraDirectories {
paths {
path {
from = file('src/main/jib')
}
path {
from = file('etc/cas')
into = '/etc/cas'
}
path {
from = file("build/libs")
into = "/docker/cas/war"
}
}
permissions = [
'/docker/entrypoint.sh': '755'
]
}
allowInsecureRegistries = project.allowInsecureRegistries
}
import com.bmuschko.gradle.docker.tasks.image.*
tasks.register("casBuildDockerImage", DockerBuildImage) {
dependsOn("build")
def imageTag = "${project.'cas.version'}"
inputDir = project.projectDir
images.add("apereo/cas:${imageTag}${imageTagPostFix}")
images.add("apereo/cas:latest${imageTagPostFix}")
if (dockerUsername != null && dockerPassword != null) {
username = dockerUsername
password = dockerPassword
}
doLast {
out.withStyle(Style.Success).println("Built CAS images successfully.")
}
}
tasks.register("casPushDockerImage", DockerPushImage) {
dependsOn("casBuildDockerImage")
def imageTag = "${project.'cas.version'}"
images.add("apereo/cas:${imageTag}${imageTagPostFix}")
images.add("apereo/cas:latest${imageTagPostFix}")
if (dockerUsername != null && dockerPassword != null) {
username = dockerUsername
password = dockerPassword
}
doLast {
out.withStyle(Style.Success).println("Pushed CAS images successfully.")
}
}
if (project.hasProperty("appServer")) {
def appServer = project.findProperty('appServer') ?: ''
out.withStyle(Style.Success).println("Building CAS version ${project.version} with application server ${appServer}")
} else {
out.withStyle(Style.Success).println("Building CAS version ${project.version} without an application server")
}
dependencies {
/**
* Do NOT modify the lines below or else you will risk breaking dependency management.
**/
implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
/**
* CAS dependencies and modules may be listed here.
*
* There is no need to specify the version number for each dependency
* since versions are all resolved and controlled by the dependency management
* plugin via the CAS bom.
**/
compileOnly "org.apereo.cas:cas-server-webapp-init-config-server"
testImplementation "org.springframework.boot:spring-boot-starter-test"
}