From e080dcf8a4fb3403b50dc292f87707879beb2fcd Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 16 Jul 2020 15:04:01 +0100 Subject: [PATCH] Configure path sensitivity of tasks' file inputs Closes gh-22359 --- .../build/cli/AbstractPackageManagerDefinitionTask.java | 4 ++++ .../properties/DocumentConfigurationProperties.java | 3 +++ .../springframework/boot/build/mavenplugin/MavenExec.java | 3 ++- .../boot/build/starters/DocumentStarters.java | 3 +++ .../boot/build/test/autoconfigure/DocumentTestSlices.java | 3 +++ .../boot/build/test/autoconfigure/TestSliceMetadata.java | 7 +++++-- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java b/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java index db068dc00c..2636fc24b5 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/cli/AbstractPackageManagerDefinitionTask.java @@ -27,6 +27,8 @@ import org.gradle.api.file.RegularFile; import org.gradle.api.provider.Provider; import org.gradle.api.tasks.InputFile; import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskExecutionException; import org.springframework.boot.build.artifactory.ArtifactoryRepository; @@ -50,6 +52,7 @@ public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask { } @InputFile + @PathSensitive(PathSensitivity.RELATIVE) public RegularFile getArchive() { return this.archive.get(); } @@ -59,6 +62,7 @@ public abstract class AbstractPackageManagerDefinitionTask extends DefaultTask { } @InputFile + @PathSensitive(PathSensitivity.RELATIVE) public File getTemplate() { return this.template; } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/context/properties/DocumentConfigurationProperties.java b/buildSrc/src/main/java/org/springframework/boot/build/context/properties/DocumentConfigurationProperties.java index c7f05a2285..9b30e1e4ed 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/context/properties/DocumentConfigurationProperties.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/context/properties/DocumentConfigurationProperties.java @@ -24,6 +24,8 @@ import org.gradle.api.Task; import org.gradle.api.file.FileCollection; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; import org.springframework.boot.build.context.properties.DocumentOptions.Builder; @@ -40,6 +42,7 @@ public class DocumentConfigurationProperties extends DefaultTask { private File outputDir; @InputFiles + @PathSensitive(PathSensitivity.RELATIVE) public FileCollection getConfigurationPropertyMetadata() { return this.configurationPropertyMetadata; } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java index 17694f11d1..1ac79d763b 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java @@ -26,6 +26,7 @@ import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.JavaExec; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskExecutionException; import org.gradle.process.internal.ExecException; import org.slf4j.Logger; @@ -50,7 +51,7 @@ public class MavenExec extends JavaExec { public void setProjectDir(File projectDir) { this.projectDir = projectDir; - getInputs().file(new File(projectDir, "pom.xml")); + getInputs().file(new File(projectDir, "pom.xml")).withPathSensitivity(PathSensitivity.RELATIVE); } @Override diff --git a/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java b/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java index fd4df45cad..4212427d33 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java @@ -36,6 +36,8 @@ import org.gradle.api.artifacts.Configuration; import org.gradle.api.file.FileCollection; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.OutputDirectory; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; import org.springframework.util.StringUtils; @@ -75,6 +77,7 @@ public class DocumentStarters extends DefaultTask { } @InputFiles + @PathSensitive(PathSensitivity.RELATIVE) public FileCollection getStarters() { return this.starters; } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java index b95ca84537..0127909047 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/DocumentTestSlices.java @@ -34,6 +34,8 @@ import org.gradle.api.Task; import org.gradle.api.file.FileCollection; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.OutputFile; +import org.gradle.api.tasks.PathSensitive; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; import org.springframework.util.ClassUtils; @@ -51,6 +53,7 @@ public class DocumentTestSlices extends DefaultTask { private File outputFile; @InputFiles + @PathSensitive(PathSensitivity.RELATIVE) public FileCollection getTestSlices() { return this.testSlices; } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java index b65bb5c384..dea130b730 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadata.java @@ -39,6 +39,7 @@ import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; import org.gradle.api.file.FileCollection; import org.gradle.api.tasks.OutputFile; +import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.TaskAction; @@ -62,8 +63,10 @@ public class TestSliceMetadata extends DefaultTask { private File outputFile; public TestSliceMetadata() { - getInputs().dir((Callable) () -> this.sourceSet.getOutput().getResourcesDir()); - getInputs().files((Callable) () -> this.sourceSet.getOutput().getClassesDirs()); + getInputs().dir((Callable) () -> this.sourceSet.getOutput().getResourcesDir()) + .withPathSensitivity(PathSensitivity.RELATIVE); + getInputs().files((Callable) () -> this.sourceSet.getOutput().getClassesDirs()) + .withPathSensitivity(PathSensitivity.RELATIVE); } public void setSourceSet(SourceSet sourceSet) {