Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue 196 #199

Merged
merged 5 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
5 changes: 5 additions & 0 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
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<Project> {
public static final String CONFIG_NAME = "spotbugs";
public static final String PLUGINS_CONFIG_NAME = "spotbugsPlugins";
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);
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ private void generateForJava(Project project, Action<? super SpotBugsTask> 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 -> {
Expand All @@ -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(
Expand Down