Skip to content

Commit 7a9a005

Browse files
authored
Avoids eager API on jvmArgs and configurations in smoke tests (#9761)
1 parent d506c27 commit 7a9a005

File tree

9 files changed

+150
-62
lines changed

9 files changed

+150
-62
lines changed

dd-smoke-tests/jboss-modules/build.gradle

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ apply from: "$rootDir/gradle/java.gradle"
88
description = 'JBoss Modules Smoke Tests.'
99

1010
configurations {
11-
jbossModulesV1
12-
jbossModulesV2
11+
register('jbossModulesV1')
12+
register('jbossModulesV2')
1313
}
1414

1515
configurations.matching { name =~ /jbossModules.*/ }.configureEach {
@@ -30,14 +30,14 @@ dependencies {
3030
}
3131

3232
tasks.register('libraryModules', Copy) {
33-
from configurations.compileClasspath
34-
into libsDirectory.dir('test-repo')
33+
from configurations.named('compileClasspath')
34+
into layout.buildDirectory.dir('test-repo')
3535
exclude '**/jboss-modules-*'
3636
rename '(.*)(-[0-9][^-]*)\\.jar', '$1/main/$1.jar'
3737
}
3838

3939
def packageTestModule(jar, name) {
40-
jar.destinationDirectory = libsDirectory.dir("test-repo/${name}/main")
40+
jar.destinationDirectory = layout.buildDirectory.dir("test-repo/${name}/main")
4141
jar.archiveFileName = "${name}.jar"
4242
jar.from sourceSets.main.output
4343
jar.include "datadog/smoketest/jbossmodules/${name}/**"
@@ -67,7 +67,7 @@ tasks.register('appModule', Jar) {
6767

6868
tasks.register('moduleDescriptors', Copy) {
6969
from sourceSets.main.output.resourcesDir
70-
into libsDirectory.dir('test-repo')
70+
into layout.buildDirectory.dir('test-repo')
7171
dependsOn "processResources"
7272
}
7373

@@ -81,7 +81,17 @@ tasks.withType(Test).configureEach {
8181
"subscribingModule",
8282
"appModule"
8383

84-
jvmArgs "-Ddatadog.smoketest.jbossmodules.JBossModulesV1=${configurations.jbossModulesV1.asPath}"
85-
jvmArgs "-Ddatadog.smoketest.jbossmodules.JBossModulesV2=${configurations.jbossModulesV2.asPath}"
86-
jvmArgs "-Ddatadog.smoketest.jbossmodules.repoPath=${libsDirectory.dir('test-repo').get()}"
84+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
85+
@Override
86+
Iterable<String> asArguments() {
87+
def jbossModulesV1Jar = configurations.named('jbossModulesV1').get().asPath
88+
def jbossModulesV2Jar = configurations.named('jbossModulesV2').get().asPath
89+
90+
return [
91+
"-Ddatadog.smoketest.jbossmodules.JBossModulesV1=${jbossModulesV1Jar}",
92+
"-Ddatadog.smoketest.jbossmodules.JBossModulesV2=${jbossModulesV2Jar}",
93+
"-Ddatadog.smoketest.jbossmodules.repoPath=${layout.buildDirectory.dir('test-repo').get()}"
94+
]
95+
}
96+
})
8797
}

dd-smoke-tests/junit-console/build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import java.time.Duration
2-
import java.time.temporal.ChronoUnit
3-
41
apply from: "$rootDir/gradle/java.gradle"
52
description = 'JUnit Console Smoke Tests.'
63

@@ -11,7 +8,16 @@ dependencies {
118
}
129

1310
tasks.withType(Test).configureEach {
14-
jvmArgs "-Ddatadog.smoketest.junit.console.jar.path=${configurations.runtimeClasspath.find { it.name.contains('junit-platform-console-standalone') }}"
11+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
12+
@Override
13+
Iterable<String> asArguments() {
14+
def consoleJarFile = configurations.named("runtimeClasspath")
15+
.get()
16+
.find { it.name.contains("junit-platform-console-standalone") }
17+
18+
return ["-Ddatadog.smoketest.junit.console.jar.path=${consoleJarFile}"]
19+
}
20+
})
1521

1622
if (project.hasProperty("mavenRepositoryProxy")) {
1723
// propagate proxy URL to tests, to then propagate it to nested Gradle builds

dd-smoke-tests/osgi/build.gradle

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import aQute.bnd.gradle.Bundle
2+
13
plugins {
2-
id 'biz.aQute.bnd.builder' version '6.1.0' apply false
4+
id 'biz.aQute.bnd.builder' version '6.1.0' apply true
35
}
46

57
repositories {
@@ -12,14 +14,12 @@ apply from: "$rootDir/gradle/java.gradle"
1214
description = 'OSGi Application Smoke Tests.'
1315

1416
configurations {
15-
equinox
16-
felix
17-
knopflerfish
18-
bundles
19-
}
20-
21-
configurations.named('bundles') {
22-
transitive = false
17+
register('equinox')
18+
register('felix')
19+
register('knopflerfish')
20+
register('bundles') {
21+
transitive = false
22+
}
2323
}
2424

2525
dependencies {
@@ -42,13 +42,18 @@ dependencies {
4242
testImplementation project(':dd-smoke-tests')
4343
}
4444

45-
tasks.named("jar", Jar) {
46-
include 'datadog/smoketest/osgi/app/**'
45+
// The bnd builder plugin modifies the jar task to post process it with bnd.
46+
// Since this cannot be disabled, we disable the jar task and create another one.
47+
tasks.named('jar', Jar) {
48+
enabled = false
4749
}
4850

49-
import aQute.bnd.gradle.Bundle
51+
def jarTask = tasks.register("appJar", Jar) {
52+
from sourceSets.main.output
53+
include 'datadog/smoketest/osgi/app/**'
54+
}
5055

51-
tasks.register('commonBundle', Bundle) {
56+
def commonBundle = tasks.register('commonBundle', Bundle) {
5257
archiveClassifier = 'common'
5358
from sourceSets.main.output
5459
include 'datadog/smoketest/osgi/common/**'
@@ -57,7 +62,7 @@ tasks.register('commonBundle', Bundle) {
5762
}
5863
}
5964

60-
tasks.register('clientBundle', Bundle) {
65+
def clientBundle = tasks.register('clientBundle', Bundle) {
6166
archiveClassifier = 'client'
6267
from sourceSets.main.output
6368
include 'datadog/smoketest/osgi/client/**'
@@ -66,7 +71,7 @@ tasks.register('clientBundle', Bundle) {
6671
}
6772
}
6873

69-
tasks.register('messagingBundle', Bundle) {
74+
def messagingBundle = tasks.register('messagingBundle', Bundle) {
7075
archiveClassifier = 'messaging'
7176
from sourceSets.main.output
7277
include 'datadog/smoketest/osgi/messaging/**'
@@ -75,7 +80,7 @@ tasks.register('messagingBundle', Bundle) {
7580
}
7681
}
7782

78-
tasks.register('publishingBundle', Bundle) {
83+
def publishingBundle = tasks.register('publishingBundle', Bundle) {
7984
archiveClassifier = 'publishing'
8085
from sourceSets.main.output
8186
include 'datadog/smoketest/osgi/publishing/**'
@@ -84,7 +89,7 @@ tasks.register('publishingBundle', Bundle) {
8489
}
8590
}
8691

87-
tasks.register('subscribingBundle', Bundle) {
92+
def subscribingBundle = tasks.register('subscribingBundle', Bundle) {
8893
archiveClassifier = 'subscribing'
8994
from sourceSets.main.output
9095
include 'datadog/smoketest/osgi/subscribing/**'
@@ -94,18 +99,34 @@ tasks.register('subscribingBundle', Bundle) {
9499
}
95100

96101
tasks.withType(Test).configureEach {
97-
dependsOn "commonBundle", "clientBundle", "messagingBundle", "publishingBundle", "subscribingBundle", "jar"
98-
99-
jvmArgs "-Ddatadog.smoketest.osgi.appJar.path=${tasks.jar.archiveFile.get()}"
100-
jvmArgs "-Ddatadog.smoketest.osgi.equinoxJar.path=${configurations.equinox.first().path}"
101-
jvmArgs "-Ddatadog.smoketest.osgi.felixJar.path=${configurations.felix.first().path}"
102-
jvmArgs "-Ddatadog.smoketest.osgi.knopflerfishJar.path=${configurations.knopflerfish.first().path}"
103-
104-
jvmArgs "-Ddatadog.smoketest.osgi.bundle.paths=" +
105-
"${tasks.commonBundle.archiveFile.get()}," +
106-
"${tasks.clientBundle.archiveFile.get()}," +
107-
"${tasks.messagingBundle.archiveFile.get()}," +
108-
"${tasks.publishingBundle.archiveFile.get()}," +
109-
"${tasks.subscribingBundle.archiveFile.get()}," +
110-
"${configurations.bundles*.path.join(',')}"
102+
dependsOn commonBundle, clientBundle, messagingBundle, publishingBundle, subscribingBundle, jarTask
103+
104+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
105+
@Override
106+
Iterable<String> asArguments() {
107+
// def jarTask = tasks.named('appJar', Jar).get()
108+
def equinoxJar = configurations.named('equinox').get().first().path
109+
def felixJar = configurations.named('felix').get().first().path
110+
def knopflerfishJar = configurations.named('knopflerfish').get().first().path
111+
112+
def bundlePaths = [
113+
commonBundle.get().archiveFile.get(),
114+
clientBundle.get().archiveFile.get(),
115+
messagingBundle.get().archiveFile.get(),
116+
publishingBundle.get().archiveFile.get(),
117+
subscribingBundle.get().archiveFile.get(),
118+
*configurations.named('bundles').get().collect {
119+
it.path
120+
}
121+
].join(',')
122+
123+
return [
124+
"-Ddatadog.smoketest.osgi.appJar.path=${jarTask.get().archiveFile.get()}",
125+
"-Ddatadog.smoketest.osgi.equinoxJar.path=${equinoxJar}",
126+
"-Ddatadog.smoketest.osgi.felixJar.path=${felixJar}",
127+
"-Ddatadog.smoketest.osgi.knopflerfishJar.path=${knopflerfishJar}",
128+
"-Ddatadog.smoketest.osgi.bundle.paths=${bundlePaths}"
129+
]
130+
}
131+
})
111132
}

dd-smoke-tests/spring-security/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ dependencies {
3232

3333

3434
tasks.withType(Test).configureEach {
35-
jvmArgs "-Ddatadog.smoketest.springboot.shadowJar.path=${tasks.jar.archiveFile.get()}"
35+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
36+
@Override
37+
Iterable<String> asArguments() {
38+
def jarTask = tasks.named('jar', Jar).get()
39+
return ["-Ddatadog.smoketest.springboot.shadowJar.path=${jarTask.archiveFile.get()}"]
40+
}
41+
})
3642
}
3743

3844
tasks.named("processResources", ProcessResources) {

dd-smoke-tests/springboot-jetty-jsp/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootWar
2+
13
plugins {
24
id 'java'
35
id 'war'
@@ -34,5 +36,12 @@ dependencies {
3436

3537
tasks.withType(Test).configureEach {
3638
dependsOn "war", "bootWar"
37-
jvmArgs "-Ddatadog.smoketest.springboot.war.path=${tasks.bootWar.archiveFile.get().getAsFile()}"
39+
40+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
41+
@Override
42+
Iterable<String> asArguments() {
43+
def bootWarTask = tasks.named('bootWar', BootWar).get()
44+
return ["-Ddatadog.smoketest.springboot.war.path=${bootWarTask.archiveFile.get().getAsFile()}"]
45+
}
46+
})
3847
}

dd-smoke-tests/springboot-jpa/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootWar
2+
13
plugins {
24
id 'java'
35
id 'war'
@@ -27,7 +29,14 @@ dependencies {
2729

2830
tasks.withType(Test).configureEach {
2931
dependsOn "bootWar"
30-
jvmArgs "-Ddatadog.smoketest.springboot.bootWar.path=${tasks.bootWar.archiveFile.get()}"
32+
33+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
34+
@Override
35+
Iterable<String> asArguments() {
36+
def bootWarTask = tasks.named('bootWar', BootWar).get()
37+
return ["-Ddatadog.smoketest.springboot.bootWar.path=${bootWarTask.archiveFile.get()}"]
38+
}
39+
})
3140
}
3241

3342
tasks.withType(GroovyCompile).configureEach {

dd-smoke-tests/springboot-tomcat-jsp/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootWar
2+
13
plugins {
24
id 'java'
35
id 'war'
@@ -34,5 +36,12 @@ dependencies {
3436

3537
tasks.withType(Test).configureEach {
3638
dependsOn "war", "bootWar"
37-
jvmArgs "-Ddatadog.smoketest.springboot.war.path=${tasks.bootWar.archiveFile.get().getAsFile()}"
39+
40+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
41+
@Override
42+
Iterable<String> asArguments() {
43+
def bootWarTask = tasks.named('bootWar', BootWar).get()
44+
return ["-Ddatadog.smoketest.springboot.war.path=${bootWarTask.archiveFile.get().getAsFile()}"]
45+
}
46+
})
3847
}

dd-smoke-tests/springboot-tomcat/build.gradle

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootWar
2+
13
plugins {
24
id 'war'
35
id 'org.springframework.boot' version '2.5.12'
@@ -43,19 +45,20 @@ dependencies {
4345

4446
tasks.register("unzip", Copy) {
4547
def zipFileNamePrefix = "tomcat"
46-
def zipPath = project.configurations.serverFile.find {
47-
it.name.startsWith(zipFileNamePrefix)
48-
}
49-
if (zipPath != null) {
50-
def zipFile = file(zipPath)
51-
def outputDir = file("${buildDir}")
52-
53-
from zipTree(zipFile)
54-
into outputDir
55-
} else {
56-
throw new GradleException("Can't find server zip file that starts with: " + zipFileNamePrefix)
48+
def serverZipTree = providers.provider {
49+
// eager access
50+
def zipPath = project.configurations.serverFile.find {
51+
it.name.startsWith(zipFileNamePrefix)
52+
}
53+
if (zipPath == null) {
54+
throw new GradleException("Can't find server zip file that starts with: " + zipFileNamePrefix)
55+
}
56+
zipTree(zipPath)
5757
}
5858

59+
from serverZipTree
60+
into layout.buildDirectory
61+
5962
// When tests are disabled this would still be run, so disable this manually
6063
onlyIf { !project.rootProject.hasProperty("skipTests") }
6164
}
@@ -109,6 +112,15 @@ tasks.matching({it.name.startsWith('compileTest')}).configureEach {
109112

110113
tasks.withType(Test).configureEach {
111114
dependsOn "war", "bootWar", "unzip"
112-
jvmArgs "-Ddatadog.smoketest.springboot.war.path=${tasks.bootWar.archiveFile.get().getAsFile()}"
113-
jvmArgs "-Ddatadog.smoketest.tomcatDir=${buildDir}/apache-${serverName}-${serverVersion}"
115+
116+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
117+
@Override
118+
Iterable<String> asArguments() {
119+
def bootWarTask = tasks.named('bootWar', BootWar).get()
120+
return [
121+
"-Ddatadog.smoketest.springboot.war.path=${bootWarTask.archiveFile.get().getAsFile()}",
122+
"-Ddatadog.smoketest.tomcatDir=${layout.buildDirectory.get()}/apache-${serverName}-${serverVersion}"
123+
]
124+
}
125+
})
114126
}

dd-smoke-tests/tracer-flare/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@ dependencies {
1414
tasks.withType(Test).configureEach {
1515
dependsOn "jar"
1616

17-
jvmArgs "-Ddatadog.smoketest.tracer-flare.jar.path=${tasks.jar.archiveFile.get()}"
17+
jvmArgumentProviders.add(new CommandLineArgumentProvider() {
18+
@Override
19+
Iterable<String> asArguments() {
20+
def jarTask = tasks.named('jar', Jar).get()
21+
return ["-Ddatadog.smoketest.tracer-flare.jar.path=${jarTask.archiveFile.get()}"]
22+
}
23+
})
1824
}

0 commit comments

Comments
 (0)