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] Disable certain errorprone checks for gradle plugins #504

Merged
merged 2 commits into from
Jan 15, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.gradle.api.Project;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.api.tasks.testing.Test;
Expand All @@ -44,7 +43,6 @@ public final class BaselineErrorProne implements Plugin<Project> {
public void apply(Project project) {
project.getPluginManager().withPlugin("java", plugin -> {
project.getPluginManager().apply(ErrorPronePlugin.class);
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
String version = Optional.ofNullable(getClass().getPackage().getImplementationVersion())
.orElse("latest.release");
project.getDependencies().add(
Expand All @@ -61,6 +59,15 @@ public void apply(Project project) {
errorProneOptions.check("StreamResourceLeak", CheckSeverity.ERROR);
}));

project.getPluginManager().withPlugin("java-gradle-plugin", appliedPlugin -> {
project.getTasks().withType(JavaCompile.class).configureEach(javaCompile ->
((ExtensionAware) javaCompile.getOptions()).getExtensions()
.configure(ErrorProneOptions.class, errorProneOptions -> {
errorProneOptions.check("Slf4jLogsafeArgs", CheckSeverity.OFF);
errorProneOptions.check("PreferSafeLoggableExceptions", CheckSeverity.OFF);
}));
});

// In case of java 8 we need to add errorprone javac compiler to bootstrap classpath of tasks that perform
// compilation or code analysis. ErrorProneJavacPluginPlugin handles JavaCompile cases via errorproneJavac
// configuration and we do similar thing for Test and Javadoc type tasks
Expand Down