spotbugs / spotbugs-gradle-plugin

https://plugins.gradle.org/plugin/com.github.spotbugs
Apache License 2.0
178 stars 68 forks source link

can't seem to disable, it's so weird #517

Open xenoterracide opened 3 years ago

xenoterracide commented 3 years ago

encountered an issue running spotbugs in one module, long story short, the only way I've found to disable spotbugs for that module was to completely remove my plugin that enabled it. I'm not even sure if this could be a bug in your code, since enabled should only be provided by the plugin base, IIRC. At the same time it seems like the only other place would be gradle itself

gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.1
❯ ./gradlew --version                                                                                                                             # backend -> master !

------------------------------------------------------------
Gradle 7.1.1
------------------------------------------------------------

Build time:   2021-07-02 12:16:43 UTC
Revision:     774525a055494e0ece39f522ac7ad17498ce032c

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.11 (AdoptOpenJDK 11.0.11+9)
OS:           Linux 5.10.42-1-MANJARO amd64

https://github.com/xenoterracide/iw-ppm-backend/blob/f9612cdc0a84d832cb592fed619a059d0a62fb44/module/authn/build.gradle.kts

KengoTODA commented 3 years ago

I cannot reproduce this problem by the following test:

diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy
index 31814c4..03f3327 100644
--- a/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy
+++ b/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy
@@ -61,6 +61,31 @@ public class Foo {
 """
     }

+    /**
+     * @see <a href="https://github.com/spotbugs/spotbugs-gradle-plugin/issues/517">The reported GitHub issue</a>
+     */
+    def "should be possible to disable"() {
+        setup:
+        buildFile << """
+tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
+    enabled = false
+}
+"""
+        when:
+        BuildResult result =
+                GradleRunner.create()
+                .withProjectDir(rootDir)
+                .withArguments(":spotbugsMain")
+                .withPluginClasspath()
+                .forwardOutput()
+                .withGradleVersion(version)
+                .build()
+
+        then:
+        result.task(":classes").outcome == TaskOutcome.SUCCESS
+        result.task(":spotbugsMain").outcome == TaskOutcome.SKIPPED
+    }
+
     def "can create spotbugsMain task depending on classes task"() {
         when:
         BuildResult result =
KengoTODA commented 3 years ago

@xenoterracide I found that the tasks does not list tasks created by the SpotBugs plugin.

git clone git@github.com:xenoterracide/iw-ppm-backend.git
cd iw-ppm-backend
git checkout f9612cdc0a84d832cb592fed619a059d0a62fb44
.\gradlew.bat :authn:tasks

It means that no task exists during the configuration phase, isn't it? I guess your project or Gradle's feature previews probably have problem around the project lifecycle.

KengoTODA commented 3 years ago

It means that no task exists during the configuration phase, isn't it?

Oops, it's not true. We have no listed tasks because of #467

KengoTODA commented 2 years ago

@xenoterracide I've solved #467 so want to reproduce this issue again. could you make a commit depending on the latest spotbugs-gradle-plugin:4.7.6 in your project?

I'm not familiar with the dependency locking, not sure how I should update that project.