From b4fccf480afedea77a9a2da4d9c97a8e629dde36 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 3 Mar 2023 19:32:02 +0000 Subject: [PATCH] Ensure that Maven plugin's intTest runs when Maven binaries change Previously, the intTest task had a dependsOn relationship with prepareMavenBinaries task. This ensured that the two tasks ran in the correct order but did not ensure that the intTest task would run if the prepared binaries had changed. This commit updates the configuration of the intTest task to wire up the output of the prepareMavenBinaries as an input of the intTest task. This ensures that the intTest task will run when the prepared binaries have changed and also creates an implicit dependsOn relationship between the two tasks. Closes gh-34474 --- .../boot/build/mavenplugin/MavenPluginPlugin.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java index 950dffdf45..d4cd48d5a7 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java @@ -80,6 +80,7 @@ import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.Sync; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskExecutionException; +import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.bundling.Jar; import org.gradle.api.tasks.javadoc.Javadoc; import org.gradle.external.javadoc.StandardJavadocDocletOptions; @@ -272,9 +273,15 @@ public class MavenPluginPlugin implements Plugin { } private void addPrepareMavenBinariesTask(Project project) { - PrepareMavenBinaries task = project.getTasks().create("prepareMavenBinaries", PrepareMavenBinaries.class); - task.setOutputDir(new File(project.getBuildDir(), "maven-binaries")); - project.getTasks().getByName(IntegrationTestPlugin.INT_TEST_TASK_NAME).dependsOn(task); + TaskProvider task = project.getTasks() + .register("prepareMavenBinaries", PrepareMavenBinaries.class, (prepareMavenBinaries) -> prepareMavenBinaries + .setOutputDir(new File(project.getBuildDir(), "maven-binaries"))); + project.getTasks() + .getByName(IntegrationTestPlugin.INT_TEST_TASK_NAME) + .getInputs() + .dir(task.map(PrepareMavenBinaries::getOutputDir)) + .withPathSensitivity(PathSensitivity.RELATIVE) + .withPropertyName("mavenBinaries"); } private void replaceVersionPlaceholder(CopySpec copy, Project project) {