@@ -110,6 +110,70 @@ 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+
122+ initializeBuildFile(buildDir)
123+ writeFile file :buildFile, text : '''
124+ |plugins {
125+ | id 'java'
126+ | id 'com.github.spotbugs'
127+ |}
128+ |
129+ |version = 1.0
130+ |
131+ |repositories {
132+ | mavenCentral()
133+ |}
134+ |spotbugsMain {
135+ | reports {
136+ | html {
137+ | required = true
138+ | stylesheet = 'fancy-hist.xsl'
139+ | }
140+ | }
141+ |}
142+ |''' . stripMargin()
143+
144+ when :
145+ GradleRunner . create()
146+ .withProjectDir(buildDir)
147+ .withArguments(' --build-cache' , ' :spotbugsMain' )
148+ .withPluginClasspath()
149+ .withGradleVersion(version)
150+ .build()
151+
152+ writeFile file :buildFile, text : readFile(buildFile). replace(' fancy-hist.xsl' , ' plain.xsl' )
153+ BuildResult result1 =
154+ GradleRunner . create()
155+ .withProjectDir(buildDir)
156+ .withArguments(' --build-cache' , ' :spotbugsMain' )
157+ .withPluginClasspath()
158+ .withGradleVersion(version)
159+ .build()
160+
161+ then :
162+ result1. task(' :spotbugsMain' ). outcome == TaskOutcome . SUCCESS
163+
164+ when :
165+ BuildResult result2 =
166+ GradleRunner . create()
167+ .withProjectDir(buildDir)
168+ .withArguments(' --build-cache' , ' :spotbugsMain' )
169+ .withPluginClasspath()
170+ .withGradleVersion(version)
171+ .build()
172+
173+ then :
174+ result2. task(' :spotbugsMain' ). outcome == TaskOutcome . FROM_CACHE
175+ }
176+
113177 private static String getHashKeyLine (BuildResult result ) {
114178 return result. output. find(' Build cache key for task \' :spotbugsMain\' is .*' )
115179 }
0 commit comments