Skip to content

Commit 9449786

Browse files
authored
wildfly-9.0 configuration was eager and misplaced (#9624)
* fix: wildfly-9.0 configuration was eager and misplaced The copy task was using the build directory as output which made all tasks depend on it. * chore: touch
1 parent 4cf7670 commit 9449786

File tree

1 file changed

+50
-31
lines changed

1 file changed

+50
-31
lines changed

dd-java-agent/instrumentation/wildfly-9.0/build.gradle

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier
2+
13
ext {
24
minJavaVersionForTests = JavaVersion.VERSION_11
35
latestDepTestMinJavaVersionForTests = JavaVersion.VERSION_17
@@ -53,53 +55,49 @@ dependencies {
5355
latestDepTestImplementation group: 'org.wildfly.core', name: 'wildfly-server', version: '+'
5456
wildflyLatestDepTest "org.wildfly:wildfly-dist:+@zip"
5557

56-
configurations.wildflyLatestDepTest.resolve()
57-
def latestWildflyVersion = configurations.wildflyLatestDepTest.resolvedConfiguration.getResolvedArtifacts().find {
58-
it.name == "wildfly-dist"
59-
}.moduleVersion.id.version
60-
61-
latestDepForkedTest {
62-
configure {
63-
jvmArgs += ["-Dtest.jboss.home=$buildDir/wildfly-${latestWildflyVersion}"]
64-
}
65-
}
66-
6758
latestDepTestRuntimeOnly project(':dd-java-agent:instrumentation:servlet:request-5')
6859
}
6960

70-
def extractWildfly(config, zipFileNamePrefix, sync) {
71-
delete(fileTree(buildDir).include("wildfly-*/standalone/deployments/**"))
72-
73-
def zipPath = config.find {
74-
it.name.startsWith(zipFileNamePrefix)
61+
def extractWildfly(NamedDomainObjectProvider<Configuration> config, String zipFileNamePrefix, Copy sync) {
62+
def zipPath = config.map { Configuration c ->
63+
c.filter { File file ->
64+
file.name.startsWith(zipFileNamePrefix)
65+
}.singleFile
66+
}.orElse(providers.provider { throw new GradleException("Can't find server zip file that starts with: " + zipFileNamePrefix) })
67+
68+
sync.from(zipTree(zipPath)) {
69+
// Strip the first path segment
70+
eachFile { FileCopyDetails f ->
71+
def segments = f.relativePath.segments
72+
if (segments.length > 1) {
73+
f.relativePath = new RelativePath(!f.directory, segments[1..-1] as String[])
74+
} else {
75+
f.exclude()
76+
}
77+
}
7578
}
76-
if (zipPath != null) {
77-
def zipFile = file(zipPath)
78-
def outputDir = file("${buildDir}")
79-
80-
sync.from zipTree(zipFile)
81-
sync.into outputDir
82-
} else {
83-
throw new GradleException("Can't find server zip file that starts with: " + zipFileNamePrefix)
79+
sync.into(layout.buildDirectory.dir("tmp/wildfly-dist-${config.name}"))
80+
sync.doFirst {
81+
delete(sync.destinationDir)
8482
}
8583
}
8684

87-
tasks.register("extractWildfly", Copy) {
85+
def extractWildflyTask = tasks.register("extractWildfly", Copy) {
8886
dependsOn configurations.wildflyTest
8987
mustRunAfter tasks.compileTestGroovy
90-
extractWildfly(configurations.wildflyTest, "wildfly-dist", it)
88+
extractWildfly(configurations.named("wildflyTest"), "wildfly-dist", it)
9189

9290
// When tests are disabled this would still be run, so disable this manually
9391
onlyIf { !project.rootProject.hasProperty("skipTests") }
9492
}
9593

96-
tasks.register("extractLatestWildfly", Copy) {
94+
def extractLatestWildfly = tasks.register("extractLatestWildfly", Copy) {
9795
mustRunAfter tasks.compileLatestDepTestGroovy
9896
mustRunAfter tasks.compileLatestDepForkedTestGroovy
9997
mustRunAfter tasks.compileLatestDepTestJava
10098
mustRunAfter tasks.compileLatestDepForkedTestJava
10199
mustRunAfter tasks.compileJava
102-
extractWildfly(configurations.wildflyLatestDepTest, "wildfly", it)
100+
extractWildfly(configurations.named("wildflyLatestDepTest"), "wildfly", it)
103101

104102
// When tests are disabled this would still be run, so disable this manually
105103
onlyIf { !project.rootProject.hasProperty("skipTests") }
@@ -163,10 +161,31 @@ processTestResources {
163161
}
164162
}
165163

166-
forkedTest {
167-
configure {
168-
jvmArgs += ["-Dtest.jboss.home=$buildDir/wildfly-21.0.0.Final"]
164+
abstract class DistributionLocationProvider implements CommandLineArgumentProvider {
165+
@InputDirectory
166+
@PathSensitive(PathSensitivity.RELATIVE)
167+
abstract Property<File> getDistribution()
168+
169+
@Override
170+
Iterable<String> asArguments() {
171+
["-Dtest.jboss.home=${distribution.get()}"]
169172
}
170173
}
171174

175+
tasks.named("forkedTest", Test) {
176+
jvmArgumentProviders.add(
177+
objects.newInstance(DistributionLocationProvider).tap {
178+
distribution = extractWildflyTask.map { it.destinationDir }
179+
}
180+
)
181+
}
182+
183+
tasks.named("latestDepForkedTest", Test) {
184+
jvmArgumentProviders.add(
185+
objects.newInstance(DistributionLocationProvider).tap {
186+
distribution = extractLatestWildfly.map { it.destinationDir }
187+
}
188+
)
189+
}
190+
172191

0 commit comments

Comments
 (0)