forked from cloudfoundry/uaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
277 lines (231 loc) · 9.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
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
import java.nio.file.Paths
buildscript {
apply(from: "dependencies.gradle")
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath(libraries.cargoGradlePlugin)
classpath(libraries.springDependencyMangementGradlePlugin)
classpath(libraries.springBootGradlePlugin)
classpath(libraries.testRetryPlugin)
classpath(libraries.gradleJcocoPlugin)
classpath(libraries.sonarqubePlugin)
}
}
apply(from: "dependencies.gradle")
def applicationPort = project.hasProperty('port') ? project.getProperty('port').toInteger() : 8080
apply(plugin: "com.bmuschko.cargo")
apply(plugin: "war")
allprojects {
apply(plugin: "io.spring.dependency-management")
apply(plugin: "org.gradle.test-retry")
apply(plugin: "org.barfuin.gradle.jacocolog")
apply(plugin: "org.sonarqube")
dependencyManagement {
imports {
mavenBom(libraries.springBootBom)
}
}
repositories {
mavenCentral()
maven {
url("https://build.shibboleth.net/nexus/content/repositories/releases/")
}
maven { url("https://repository.mulesoft.org/releases/") }
}
}
subprojects {
apply(plugin: "java")
configurations.all {
exclude(group: "org.hamcrest", module: "hamcrest-all")
exclude(group: "org.hamcrest", module: "hamcrest-core")
exclude(group: "org.hamcrest", module: "hamcrest-library")
exclude(group: "org.springframework.boot", module: "spring-boot-starter-logging")
exclude(group: "org.apache.directory.server", module: "apacheds-core")
exclude(group: "org.apache.directory.server", module: "apacheds-protocol-ldap")
exclude(group: "org.skyscreamer", module: "jsonassert")
exclude(group: "com.vaadin.external.google", module: "android-json")
}
dependencies {
testImplementation(libraries.springBootStarterTest)
testImplementation(libraries.hamcrest)
testImplementation(libraries.junit5JupiterApi)
testImplementation(libraries.junit5JupiterParams)
testRuntimeOnly(libraries.junit5JupiterEngine)
testRuntimeOnly(libraries.junitVintageEngine)
testImplementation(libraries.unboundIdLdapSdk)
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
}
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none", "-nowarn"]
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
test {
maxParallelForks = 1
// when failFast = true AND retry is on, there is a serious issue:
// gradle might stop the test run due to the failFast but still concludes with BUILD SUCCESSFUL (if the retry is successful)
failFast = false
useJUnitPlatform()
jvmArgs += ["-Xmx1024m", "-XX:+StartAttachListener", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/var/log/uaa-tests.hprof"]
retry {
def failOnPassedAfterRetrySystemProperty = Boolean.parseBoolean(
System.getProperty("failOnPassedAfterRetry", "false"));
if (!failOnPassedAfterRetrySystemProperty)
logger.warn("retry: Flaky tests will not make the test run fail because failOnPassedAfterRetry is false.")
// Configure the retry extension
failOnPassedAfterRetry = failOnPassedAfterRetrySystemProperty
maxFailures = Integer.parseInt(System.getProperty("maxFailures", "3"))
maxRetries = Integer.parseInt(System.getProperty("maxRetries", "1"))
}
testLogging {
events("skipped", "failed", "passed")
exceptionFormat("full")
// Uncomment the following line to see all standard output from tests (there's a ton of it!)
//showStandardStreams = true
}
}
task integrationTest(type: Test) {
dependsOn rootProject.cargoStartLocal
useJUnitPlatform()
testLogging {
events("skipped", "failed", "passed")
exceptionFormat("full")
// Uncomment the following line to see all standard output from tests (there's a ton of it!)
//showStandardStreams = true
}
}
task generateDocs() {}
task allDeps(type: DependencyReportTask) {}
task writeNewPom() {
doLast {
pom {
project {
licenses {
license {
name("The Apache Software License, Version 2.0")
url("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution("repo")
}
}
}
}.writeTo("./pom.xml")
}
}
repositories {
mavenCentral()
maven {
url("https://jitpack.io")
}
maven {
url("https://repo.maven.apache.org/maven2")
}
}
}
cargo {
containerId = "tomcat9x"
port = applicationPort
if (JavaVersion.current() < JavaVersion.VERSION_17) {
throw new GradleException("This build must be run with Java version [ " + JavaVersion.VERSION_17 + " ] or greater. Your Java version is [ " + JavaVersion.current() + " ]")
}
deployable {
file = file("samples/api/build/libs/cloudfoundry-identity-api-" + version + ".war")
context = "api"
}
deployable {
file = file("samples/app/build/libs/cloudfoundry-identity-app-" + version + ".war")
context = "app"
}
deployable {
file = file("uaa/build/libs/cloudfoundry-identity-uaa-" + version + ".war")
context = "uaa"
}
local {
configHomeDir = file(Paths.get(System.getProperty("java.io.tmpdir") + "/uaa-${applicationPort}"))
startStopTimeout = Integer.parseInt(System.getProperty("startStopTimeout", "540000"))
rmiPort = applicationPort + 10
jvmArgs = ""
jvmArgs = String.format("%s -DCLOUDFOUNDRY_CONFIG_PATH='%s'", jvmArgs, file("scripts/cargo").getAbsolutePath())
jvmArgs = String.format("%s -Dlogging.config='%s'", jvmArgs, file("scripts/cargo/log4j2.properties").getAbsolutePath())
jvmArgs = String.format("%s -Dstatsd.enabled=true", jvmArgs)
String activeSpringProfiles = System.getProperty("spring.profiles.active", "").split(',');
if (activeSpringProfiles.contains("debugs") || Boolean.valueOf(System.getProperty("xdebugs"))) {
jvmArgs = String.format("%s -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005", jvmArgs)
}
else if (activeSpringProfiles.contains("debug") || Boolean.valueOf(System.getProperty("xdebug"))) {
jvmArgs = String.format("%s -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", jvmArgs)
}
outputFile = file("uaa/build/reports/tests/uaa-server.log")
configFile {
files = files("scripts/cargo/tomcat-conf/context.xml")
toDir = "conf"
}
systemProperties {
property("SECRETS_DIR", System.getProperty("SECRETS_DIR", file("scripts/cargo").getAbsolutePath()))
property("spring.profiles.active", System.getProperty("spring.profiles.active", "default"))
property("metrics.perRequestMetrics", System.getProperty("metrics.perRequestMetrics", "true"))
property("smtp.host", "localhost")
property("smtp.port", 2525)
property("java.security.egd", "file:/dev/./urandom")
}
containerProperties {
property('cargo.tomcat.ajp.port', applicationPort + 20)
}
installer {
installUrl = "https://repo1.maven.org/maven2/org/apache/tomcat/tomcat/" + tomcatCargoVersion + "/tomcat-" + tomcatCargoVersion + ".tar.gz"
downloadDir = file("$buildDir/download")
extractDir = file("$buildDir/extract")
}
}
}
sonarqube {
properties {
property "sonar.projectKey", "cloudfoundry-identity-parent"
property "sonar.organization", "cloudfoundry-1"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.exclusions", "samples/**/*.*,**/*Test.java,**/*Tests.java,**/*IT.java"
property "sonar.java.source", JavaVersion.current()
}
}
project.gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
project.allprojects.collect({ it.tasks.withType(Test) }).flatten().each {
it.systemProperty("spring.profiles.active", System.getProperty("spring.profiles.active", "default"))
it.systemProperty("testId", System.getProperty("testId", ""))
}
}
//task declarations
task run(dependsOn: cargoRunLocal)
task manifests(dependsOn: assemble, type: Copy) {
from("uaa/src/test/resources/sample-manifests") {
include("**/*.yml")
filter(ReplaceTokens,
tokens: [
version : version,
app : System.getProperty("app", "myuaa"),
appdomain: System.getProperty("app-domain", "bosh-lite.com"),
]
)
}
into("build/sample-manifests")
}
task cleanCargoConfDir {
delete(file(System.getProperty("java.io.tmpdir") + "/cargo/uaa-${applicationPort}"))
try {
Files.createDirectory(Paths.get(System.getProperty("java.io.tmpdir") + "/uaa-${applicationPort}"))
} catch (ignored) {}
}
task integrationTest(type: Test, dependsOn: subprojects.integrationTest) {
finalizedBy cargoStopLocal
}
// task dependencies
assemble.dependsOn(subprojects.assemble)
test.dependsOn(subprojects.test)
test.mustRunAfter(integrationTest)
cargoStartLocal.dependsOn(assemble)
cargoRunLocal.dependsOn(cleanCargoConfDir, assemble)