|
| 1 | +import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier |
| 2 | + |
1 | 3 | ext { |
2 | 4 | minJavaVersionForTests = JavaVersion.VERSION_11 |
3 | 5 | latestDepTestMinJavaVersionForTests = JavaVersion.VERSION_17 |
@@ -53,53 +55,49 @@ dependencies { |
53 | 55 | latestDepTestImplementation group: 'org.wildfly.core', name: 'wildfly-server', version: '+' |
54 | 56 | wildflyLatestDepTest "org.wildfly:wildfly-dist:+@zip" |
55 | 57 |
|
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 | | - |
67 | 58 | latestDepTestRuntimeOnly project(':dd-java-agent:instrumentation:servlet:request-5') |
68 | 59 | } |
69 | 60 |
|
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 | + } |
75 | 78 | } |
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) |
84 | 82 | } |
85 | 83 | } |
86 | 84 |
|
87 | | -tasks.register("extractWildfly", Copy) { |
| 85 | +def extractWildflyTask = tasks.register("extractWildfly", Copy) { |
88 | 86 | dependsOn configurations.wildflyTest |
89 | 87 | mustRunAfter tasks.compileTestGroovy |
90 | | - extractWildfly(configurations.wildflyTest, "wildfly-dist", it) |
| 88 | + extractWildfly(configurations.named("wildflyTest"), "wildfly-dist", it) |
91 | 89 |
|
92 | 90 | // When tests are disabled this would still be run, so disable this manually |
93 | 91 | onlyIf { !project.rootProject.hasProperty("skipTests") } |
94 | 92 | } |
95 | 93 |
|
96 | | -tasks.register("extractLatestWildfly", Copy) { |
| 94 | +def extractLatestWildfly = tasks.register("extractLatestWildfly", Copy) { |
97 | 95 | mustRunAfter tasks.compileLatestDepTestGroovy |
98 | 96 | mustRunAfter tasks.compileLatestDepForkedTestGroovy |
99 | 97 | mustRunAfter tasks.compileLatestDepTestJava |
100 | 98 | mustRunAfter tasks.compileLatestDepForkedTestJava |
101 | 99 | mustRunAfter tasks.compileJava |
102 | | - extractWildfly(configurations.wildflyLatestDepTest, "wildfly", it) |
| 100 | + extractWildfly(configurations.named("wildflyLatestDepTest"), "wildfly", it) |
103 | 101 |
|
104 | 102 | // When tests are disabled this would still be run, so disable this manually |
105 | 103 | onlyIf { !project.rootProject.hasProperty("skipTests") } |
@@ -163,10 +161,31 @@ processTestResources { |
163 | 161 | } |
164 | 162 | } |
165 | 163 |
|
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()}"] |
169 | 172 | } |
170 | 173 | } |
171 | 174 |
|
| 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 | + |
172 | 191 |
|
0 commit comments