diff --git a/.idea/compiler.xml b/.idea/compiler.xml index cf7d3df9..a0ec8843 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -30,7 +30,7 @@ - + diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy index 4ab8d4f6..e91a9f5b 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy @@ -377,4 +377,19 @@ public class Foo { result.task(":classes").outcome == TaskOutcome.SUCCESS result.task(":spotbugsMain").outcome == TaskOutcome.NO_SOURCE } + + def "can run analysis when check task is triggered"() { + when: + BuildResult result = + GradleRunner.create() + .withProjectDir(rootDir) + .withArguments("clean", "check") + .withPluginClasspath() + .forwardOutput() + .withGradleVersion(version) + .build() + + then: + result.task(":spotbugsMain").outcome == TaskOutcome.SUCCESS + } } diff --git a/src/main/groovy/com/github/spotbugs/snom/SpotBugsPlugin.java b/src/main/groovy/com/github/spotbugs/snom/SpotBugsPlugin.java index 29c282aa..59470b48 100644 --- a/src/main/groovy/com/github/spotbugs/snom/SpotBugsPlugin.java +++ b/src/main/groovy/com/github/spotbugs/snom/SpotBugsPlugin.java @@ -18,6 +18,8 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SpotBugsPlugin implements Plugin { public static final String CONFIG_NAME = "spotbugs"; @@ -25,6 +27,8 @@ public class SpotBugsPlugin implements Plugin { public static final String SLF4J_CONFIG_NAME = "spotbugsSlf4j"; public static final String EXTENSION_NAME = "spotbugs"; + private final Logger log = LoggerFactory.getLogger(getClass()); + @Override public void apply(Project project) { project.getPluginManager().apply(SpotBugsBasePlugin.class); @@ -34,6 +38,7 @@ public void apply(Project project) { private void createTasks(Project project, SpotBugsExtension extension) { @Nullable Task check = project.getTasks().findByName("check"); + log.debug("check task {}", check == null ? "not found" : "found"); new SpotBugsTaskFactory() .generate( project, diff --git a/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsTaskFactory.java b/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsTaskFactory.java index c64b9184..f3c138ed 100644 --- a/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsTaskFactory.java +++ b/src/main/groovy/com/github/spotbugs/snom/internal/SpotBugsTaskFactory.java @@ -44,10 +44,10 @@ private void generateForJava(Project project, Action confi .all( sourceSet -> { String name = sourceSet.getTaskName("spotbugs", null); - log.debug("Creating SpotBugsTaskForJava for {}", sourceSet); + log.debug("Creating SpotBugsTask for {}", sourceSet); project .getTasks() - .register( + .create( name, SpotBugsTask.class, task -> { @@ -74,7 +74,7 @@ private void generateForAndroid( .all( task -> { String name = GUtil.toLowerCamelCase("spotbugs " + task.getVariantName()); - log.debug("Creating SpotBugsTaskForAndroid for {}", task); + log.debug("Creating SpotBugsTask for {}", task); project .getTasks() .register(