Skip to content

Commit 84b88c0

Browse files
committed
more
1 parent 505554d commit 84b88c0

File tree

3 files changed

+96
-25
lines changed

3 files changed

+96
-25
lines changed

instrumentation/quarkus-resteasy-reactive/quarkus2-testing/build.gradle.kts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,39 @@ val quarkusTestBaseRuntimeClasspathConfiguration by configurations.creating {
3838
val quarkusTestCompileOnlyConfiguration by configurations.creating {
3939
}
4040

41-
val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat").get().asFile.toPath()
41+
val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat")
4242

43-
val buildModel = tasks.register("buildModel") {
44-
dependsOn(configurations.named("testRuntimeClasspath"))
43+
abstract class BuildQuarkusModelTask : DefaultTask() {
44+
@get:OutputFile
45+
abstract val modelFile: RegularFileProperty
4546

46-
if (testModelPath.notExists()) {
47-
doLast {
47+
@TaskAction
48+
fun buildModel() {
49+
val modelPath = modelFile.get().asFile.toPath()
50+
if (modelPath.notExists()) {
4851
val modelParameter = ModelParameterImpl()
4952
modelParameter.mode = LaunchMode.TEST.toString()
5053
val model = GradleApplicationModelBuilder().buildAll(
5154
ApplicationModel::class.java.getName(),
5255
modelParameter,
5356
project
5457
)
55-
BootstrapUtils.serializeAppModel(model as ApplicationModel?, testModelPath)
58+
BootstrapUtils.serializeAppModel(model as ApplicationModel?, modelPath)
5659
}
5760
}
58-
outputs.file(testModelPath)
61+
}
62+
63+
val buildModel = tasks.register<BuildQuarkusModelTask>("buildModel") {
64+
dependsOn(configurations.named("testRuntimeClasspath"))
65+
modelFile.set(testModelPath)
66+
notCompatibleWithConfigurationCache("Uses Quarkus GradleApplicationModelBuilder which requires Project at execution time")
5967
}
6068

6169
tasks {
6270
test {
6371
dependsOn(buildModel)
6472

65-
systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.toString())
73+
systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.get().asFile.absolutePath)
6674
}
6775

6876
if (findProperty("denyUnsafe") as Boolean) {

instrumentation/quarkus-resteasy-reactive/quarkus3-testing/build.gradle.kts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,39 @@ val quarkusTestBaseRuntimeClasspathConfiguration by configurations.creating {
4545
val quarkusTestCompileOnlyConfiguration by configurations.creating {
4646
}
4747

48-
val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat").get().asFile.toPath()
48+
val testModelPath = layout.buildDirectory.file("quarkus-app-test-model.dat")
4949

50-
val buildModel = tasks.register("buildModel") {
51-
dependsOn(configurations.named("testRuntimeClasspath"))
50+
abstract class BuildQuarkusModelTask : DefaultTask() {
51+
@get:OutputFile
52+
abstract val modelFile: RegularFileProperty
5253

53-
if (testModelPath.notExists()) {
54-
doLast {
54+
@TaskAction
55+
fun buildModel() {
56+
val modelPath = modelFile.get().asFile.toPath()
57+
if (modelPath.notExists()) {
5558
val modelParameter = ModelParameterImpl()
5659
modelParameter.mode = LaunchMode.TEST.toString()
5760
val model = GradleApplicationModelBuilder().buildAll(
5861
ApplicationModel::class.java.getName(),
5962
modelParameter,
6063
project
6164
)
62-
BootstrapUtils.serializeAppModel(model as ApplicationModel?, testModelPath)
65+
BootstrapUtils.serializeAppModel(model as ApplicationModel?, modelPath)
6366
}
6467
}
65-
outputs.file(testModelPath)
68+
}
69+
70+
val buildModel = tasks.register<BuildQuarkusModelTask>("buildModel") {
71+
dependsOn(configurations.named("testRuntimeClasspath"))
72+
modelFile.set(testModelPath)
73+
notCompatibleWithConfigurationCache("Uses Quarkus GradleApplicationModelBuilder which requires Project at execution time")
6674
}
6775

6876
tasks {
6977
test {
7078
dependsOn(buildModel)
7179

72-
systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.toString())
80+
systemProperty("quarkus-internal-test.serialized-app-model.path", testModelPath.get().asFile.absolutePath)
7381
}
7482

7583
if (findProperty("denyUnsafe") as Boolean) {

testing/agent-for-testing/build.gradle.kts

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,76 @@ dependencies {
2424
testImplementation("io.opentelemetry:opentelemetry-api")
2525
}
2626

27+
abstract class ExtractAgentJar : DefaultTask() {
28+
@get:InputFiles
29+
@get:PathSensitive(PathSensitivity.NONE)
30+
abstract val agentJar: ConfigurableFileCollection
31+
32+
@get:OutputDirectory
33+
abstract val extractDir: DirectoryProperty
34+
35+
@get:Inject
36+
abstract val archiveOperations: ArchiveOperations
37+
38+
@get:Inject
39+
abstract val fileSystemOperations: FileSystemOperations
40+
41+
@TaskAction
42+
fun extract() {
43+
fileSystemOperations.sync {
44+
from(archiveOperations.zipTree(agentJar.singleFile))
45+
into(extractDir)
46+
}
47+
}
48+
}
49+
50+
abstract class ExtractAgentManifest : DefaultTask() {
51+
@get:InputFiles
52+
@get:PathSensitive(PathSensitivity.NONE)
53+
abstract val agentJar: ConfigurableFileCollection
54+
55+
@get:OutputFile
56+
abstract val manifestFile: RegularFileProperty
57+
58+
@get:Inject
59+
abstract val archiveOperations: ArchiveOperations
60+
61+
@get:Inject
62+
abstract val fileSystemOperations: FileSystemOperations
63+
64+
@TaskAction
65+
fun extract() {
66+
fileSystemOperations.copy {
67+
from(archiveOperations.zipTree(agentJar.singleFile))
68+
include("META-INF/MANIFEST.MF")
69+
into(temporaryDir)
70+
}
71+
manifestFile.get().asFile.writeBytes(
72+
temporaryDir.resolve("META-INF/MANIFEST.MF").readBytes()
73+
)
74+
}
75+
}
76+
77+
val extractAgent = tasks.register<ExtractAgentJar>("extractAgent") {
78+
agentJar.from(agent)
79+
extractDir.set(layout.buildDirectory.dir("tmp/agent-extracted"))
80+
}
81+
82+
val extractManifest = tasks.register<ExtractAgentManifest>("extractManifest") {
83+
agentJar.from(agent)
84+
manifestFile.set(layout.buildDirectory.file("tmp/agent-manifest/MANIFEST.MF"))
85+
}
86+
2787
tasks {
2888
jar {
29-
dependsOn(agent)
30-
from(agent.elements.map { zipTree(it.single()) })
89+
dependsOn(extractAgent)
90+
from(extractAgent.flatMap { it.extractDir })
3191
from(extensionLibs) {
3292
into("extensions")
3393
}
3494

35-
manifest.from(
36-
agent.elements.map {
37-
zipTree(it.single()).matching {
38-
include("META-INF/MANIFEST.MF")
39-
}.singleFile
40-
}
41-
)
95+
dependsOn(extractManifest)
96+
manifest.from(extractManifest.flatMap { it.manifestFile })
4297
}
4398

4499
afterEvaluate {

0 commit comments

Comments
 (0)