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
pull/34587/head
Andy Wilkinson 2 years ago
parent 10d71f5645
commit b4fccf480a

@ -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<Project> {
}
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<PrepareMavenBinaries> 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) {

Loading…
Cancel
Save