Skip to content
Merged
Changes from 1 commit
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 @@ -22,9 +22,11 @@
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.compile.JavaCompile;

public final class BaselineNullAway implements Plugin<Project> {
Expand All @@ -50,7 +52,20 @@ private void applyToProject(Project project) {
+ "beware this compromises build reproducibility");
return "latest.release";
});
project.getDependencies().add("errorprone", "com.palantir.baseline:baseline-null-away:" + version);
project.getConfigurations()
.matching(new Spec<Configuration>() {
@Override
public boolean isSatisfiedBy(Configuration config) {
return "errorprone".equals(config.getName());
}
})
.configureEach(new Action<Configuration>() {
@Override
public void execute(Configuration _files) {
project.getDependencies()
.add("errorprone", "com.palantir.baseline:baseline-null-away:" + version);
}
});
configureErrorProneOptions(project, new Action<ErrorProneOptions>() {
@Override
public void execute(ErrorProneOptions options) {
Expand All @@ -60,11 +75,18 @@ public void execute(ErrorProneOptions options) {
});
}

private static void configureErrorProneOptions(Project project, Action<ErrorProneOptions> action) {
project.getTasks().withType(JavaCompile.class).configureEach(new Action<JavaCompile>() {
private static void configureErrorProneOptions(Project proj, Action<ErrorProneOptions> action) {
proj.afterEvaluate(new Action<Project>() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches our internal plugin configuration

@Override
public void execute(JavaCompile javaCompile) {
((ExtensionAware) javaCompile.getOptions()).getExtensions().configure(ErrorProneOptions.class, action);
public void execute(Project project) {
project.getTasks().withType(JavaCompile.class).configureEach(new Action<JavaCompile>() {
@Override
public void execute(JavaCompile javaCompile) {
((ExtensionAware) javaCompile.getOptions())
.getExtensions()
.configure(ErrorProneOptions.class, action);
}
});
}
});
}
Expand Down