@@ -110,6 +110,71 @@ class CacheabilityFunctionalTest extends Specification {
110110 hashKeyLine1 == hashKeyLine2
111111 }
112112
113+ /**
114+ * @see <a href =" https://github.com/spotbugs/spotbugs-gradle-plugin/issues/710" >GitHub Issue</a>
115+ */
116+ def ' build cache is invalidate when user changes stylesheet' () {
117+ given :
118+ def buildDir = Files . createTempDirectory(null ). toFile()
119+ def buildFile = new File (buildDir, ' build.gradle' )
120+ def version = System . getProperty(' snom.test.functional.gradle' , GradleVersion . current(). version)
121+ def buildFileContent = '''
122+ |plugins {
123+ | id 'java'
124+ | id 'com.github.spotbugs'
125+ |}
126+ |
127+ |version = 1.0
128+ |
129+ |repositories {
130+ | mavenCentral()
131+ |}
132+ |spotbugsMain {
133+ | reports {
134+ | html {
135+ | required = true
136+ | stylesheet = 'fancy-hist.xsl'
137+ | }
138+ | }
139+ |}
140+ |''' . stripMargin()
141+
142+ initializeBuildFile(buildDir)
143+ buildFile. write(buildFileContent)
144+
145+ when :
146+ GradleRunner . create()
147+ .withProjectDir(buildDir)
148+ .withArguments(' --build-cache' , ' :spotbugsMain' )
149+ .withPluginClasspath()
150+ .withGradleVersion(version)
151+ .build()
152+
153+ buildFile. write(buildFileContent. replace(' fancy-hist.xsl' , ' plain.xsl' ))
154+ BuildResult result1 =
155+ GradleRunner . create()
156+ .withProjectDir(buildDir)
157+ .withArguments(' --build-cache' , ' :spotbugsMain' )
158+ .withPluginClasspath()
159+ .withGradleVersion(version)
160+ .build()
161+
162+ then :
163+ result1. task(' :spotbugsMain' ). outcome == TaskOutcome . SUCCESS
164+
165+ when :
166+ BuildResult result2 =
167+ GradleRunner . create()
168+ .withProjectDir(buildDir)
169+ .withArguments(' --build-cache' , ' :spotbugsMain' )
170+ .withPluginClasspath()
171+ .withGradleVersion(version)
172+ .build()
173+
174+ then :
175+ result2. task(' :spotbugsMain' ). outcome == TaskOutcome . UP_TO_DATE
176+ }
177+
113178 private static String getHashKeyLine (BuildResult result ) {
114179 return result. output. find(' Build cache key for task \' :spotbugsMain\' is .*' )
115180 }
0 commit comments