diff --git a/pulsar-broker/build.gradle.kts b/pulsar-broker/build.gradle.kts index 357c2163e029d..07d98d800aade 100644 --- a/pulsar-broker/build.gradle.kts +++ b/pulsar-broker/build.gradle.kts @@ -142,27 +142,43 @@ evaluationDependsOn(":pulsar-io") evaluationDependsOn(":pulsar-functions") // NAR/JAR files needed by broker tests (mirrors Maven's maven-dependency-plugin config). +// Resolve through dependency configurations instead of cross-project task references. +val testNars by configurations.creating { + isCanBeResolved = true + isCanBeConsumed = false + attributes { + attribute(org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, "nar") + } +} +val testExamplesJar by configurations.creating { + isCanBeResolved = true + isCanBeConsumed = false +} + +dependencies { + testNars(project(":pulsar-functions:pulsar-functions-api-examples-builtin")) + testNars(project(":pulsar-io:pulsar-io-data-generator")) + testNars(project(":pulsar-io:pulsar-io-batch-data-generator")) + testExamplesJar(project(":pulsar-functions:pulsar-functions-api-examples")) +} + tasks.withType { - dependsOn( - ":pulsar-functions:pulsar-functions-api-examples:jar", - ":pulsar-functions:pulsar-functions-api-examples-builtin:nar", - ":pulsar-io:pulsar-io-data-generator:nar", - ":pulsar-io:pulsar-io-batch-data-generator:nar", - ) + dependsOn(testNars, testExamplesJar) + val narFiles = testNars.incoming.artifacts.resolvedArtifacts + val jarFiles = testExamplesJar.incoming.artifacts.resolvedArtifacts doFirst { - fun narPath(projectPath: String): String { - val p = rootProject.project(projectPath) - return p.tasks.named("nar").get().outputs.files.singleFile.absolutePath - } - fun jarPath(projectPath: String): String { - val p = rootProject.project(projectPath) - return p.tasks.named("jar").get().archiveFile.get().asFile.absolutePath + val narMap = narFiles.get().associate { + val id = it.id.componentIdentifier as org.gradle.api.artifacts.component.ProjectComponentIdentifier + id.projectPath to it.file.absolutePath } - val examplesJarPath = jarPath(":pulsar-functions:pulsar-functions-api-examples") + val examplesJarPath = jarFiles.get().first().file.absolutePath systemProperty("pulsar-functions-api-examples.jar.path", examplesJarPath) - systemProperty("pulsar-functions-api-examples.nar.path", narPath(":pulsar-functions:pulsar-functions-api-examples-builtin")) - systemProperty("pulsar-io-data-generator.nar.path", narPath(":pulsar-io:pulsar-io-data-generator")) - systemProperty("pulsar-io-batch-data-generator.nar.path", narPath(":pulsar-io:pulsar-io-batch-data-generator")) + systemProperty("pulsar-functions-api-examples.nar.path", + narMap[":pulsar-functions:pulsar-functions-api-examples-builtin"]!!) + systemProperty("pulsar-io-data-generator.nar.path", + narMap[":pulsar-io:pulsar-io-data-generator"]!!) + systemProperty("pulsar-io-batch-data-generator.nar.path", + narMap[":pulsar-io:pulsar-io-batch-data-generator"]!!) // A valid jar that is not a valid nar — used for invalid-nar tests systemProperty("pulsar-io-invalid.nar.path", examplesJarPath) } diff --git a/pulsar-functions/worker/build.gradle.kts b/pulsar-functions/worker/build.gradle.kts index b233a4b046043..734dc9da0ae3d 100644 --- a/pulsar-functions/worker/build.gradle.kts +++ b/pulsar-functions/worker/build.gradle.kts @@ -113,6 +113,7 @@ dependencies { } tasks.withType { + dependsOn(testNars, testExamplesJar) // Map resolved NAR/JAR files to system properties val narFiles = testNars.incoming.artifacts.resolvedArtifacts val jarFiles = testExamplesJar.incoming.artifacts.resolvedArtifacts