Skip to content

Commit

Permalink
fix: depends on check task after java-base plugin is applied to project
Browse files Browse the repository at this point in the history
  • Loading branch information
KengoTODA committed Mar 10, 2020
1 parent 68bc009 commit 0f6b181
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.github.spotbugs.snom;

import com.github.spotbugs.snom.internal.SpotBugsTaskFactory;
import edu.umd.cs.findbugs.annotations.Nullable;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
Expand All @@ -33,20 +32,20 @@ public class SpotBugsPlugin implements Plugin<Project> {
public void apply(Project project) {
project.getPluginManager().apply(SpotBugsBasePlugin.class);
SpotBugsExtension extension = project.getExtensions().findByType(SpotBugsExtension.class);
project
.getPluginManager()
.withPlugin(
"java-base",
javaBase -> {
log.debug(
"The javaBase plugin has been applied, so making the check task depending on all of SpotBugsTask");
Task check = project.getTasks().getByName("check");
project.getTasks().withType(SpotBugsTask.class, check::dependsOn);
});
createTasks(project, extension);
}

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,
task -> {
if (check != null) {
check.dependsOn(task);
}
task.init(extension);
});
new SpotBugsTaskFactory().generate(project, task -> task.init(extension));
}
}

0 comments on commit 0f6b181

Please sign in to comment.