diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy
index c561a406..ab708d57 100644
--- a/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy
+++ b/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy
@@ -110,6 +110,71 @@ class CacheabilityFunctionalTest extends Specification {
hashKeyLine1 == hashKeyLine2
}
+ /**
+ * @see GitHub Issue
+ */
+ def 'build cache is invalidate when user changes stylesheet'() {
+ given:
+ def buildDir = Files.createTempDirectory(null).toFile()
+ def buildFile = new File(buildDir, 'build.gradle')
+ def version = System.getProperty('snom.test.functional.gradle', GradleVersion.current().version)
+ def buildFileContent = '''
+ |plugins {
+ | id 'java'
+ | id 'com.github.spotbugs'
+ |}
+ |
+ |version = 1.0
+ |
+ |repositories {
+ | mavenCentral()
+ |}
+ |spotbugsMain {
+ | reports {
+ | html {
+ | required = true
+ | stylesheet = 'fancy-hist.xsl'
+ | }
+ | }
+ |}
+ |'''.stripMargin()
+
+ initializeBuildFile(buildDir)
+ buildFile.write(buildFileContent)
+
+ when:
+ GradleRunner.create()
+ .withProjectDir(buildDir)
+ .withArguments('--build-cache', ':spotbugsMain')
+ .withPluginClasspath()
+ .withGradleVersion(version)
+ .build()
+
+ buildFile.write(buildFileContent.replace('fancy-hist.xsl', 'plain.xsl'))
+ BuildResult result1 =
+ GradleRunner.create()
+ .withProjectDir(buildDir)
+ .withArguments('--build-cache', ':spotbugsMain')
+ .withPluginClasspath()
+ .withGradleVersion(version)
+ .build()
+
+ then:
+ result1.task(':spotbugsMain').outcome == TaskOutcome.SUCCESS
+
+ when:
+ BuildResult result2 =
+ GradleRunner.create()
+ .withProjectDir(buildDir)
+ .withArguments('--build-cache', ':spotbugsMain')
+ .withPluginClasspath()
+ .withGradleVersion(version)
+ .build()
+
+ then:
+ result2.task(':spotbugsMain').outcome == TaskOutcome.UP_TO_DATE
+ }
+
private static String getHashKeyLine(BuildResult result) {
return result.output.find('Build cache key for task \':spotbugsMain\' is .*')
}
diff --git a/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsHtmlReport.java b/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsHtmlReport.java
index f7c20d2c..39331eb4 100644
--- a/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsHtmlReport.java
+++ b/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsHtmlReport.java
@@ -24,6 +24,7 @@
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.resources.TextResource;
+import org.gradle.api.tasks.Input;
public abstract class SpotBugsHtmlReport extends SpotBugsReport {
private final Property stylesheet;
@@ -56,6 +57,7 @@ public String getName() {
}
@Override
+ @Input
public TextResource getStylesheet() {
if (stylesheet.isPresent()) {
return stylesheet.get();