diff --git a/README.md b/README.md index df4e0bcd4..3b2523249 100644 --- a/README.md +++ b/README.md @@ -124,11 +124,7 @@ Rules can be suppressed at the project level, or have their severity modified, b ```gradle tasks.withType(JavaCompile).configureEach { - options.errorprone.errorproneArgs += ['-Xep:Slf4jLogsafeArgs:OFF'] - // alternatively, using the DSL: - options.errorprone { - check('Slf4jLogsafeArgs', CheckSeverity.OFF) - } + options.errorprone.disable 'Slf4jLogsafeArgs' } ``` diff --git a/changelog/@unreleased/pr-1371.v2.yml b/changelog/@unreleased/pr-1371.v2.yml new file mode 100644 index 000000000..cbca81df7 --- /dev/null +++ b/changelog/@unreleased/pr-1371.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Upgrade gradle-errorprone + links: + - https://github.com/palantir/gradle-baseline/pull/1371 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java index 4bb0860f6..5066a38ab 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineErrorProne.java @@ -197,16 +197,19 @@ private static void configureErrorProneOptions( if (project.hasProperty(DISABLE_PROPERY)) { log.info("Disabling baseline-error-prone for {} due to {}", project, DISABLE_PROPERY); - errorProneOptions.setEnabled(false); + errorProneOptions.getEnabled().set(false); } else { - errorProneOptions.setEnabled(true); + errorProneOptions.getEnabled().set(true); } - errorProneOptions.setDisableWarningsInGeneratedCode(true); + errorProneOptions.getDisableWarningsInGeneratedCode().set(true); String projectPath = project.getProjectDir().getPath(); String separator = Pattern.quote(Paths.get(projectPath).getFileSystem().getSeparator()); - errorProneOptions.setExcludedPaths(String.format( - "%s%s(build|src%sgenerated.*)%s.*", Pattern.quote(projectPath), separator, separator, separator)); + errorProneOptions + .getExcludedPaths() + .set(String.format( + "%s%s(build|src%sgenerated.*)%s.*", + Pattern.quote(projectPath), separator, separator, separator)); errorProneOptions.check("CatchSpecificity", CheckSeverity.OFF); errorProneOptions.check("UnusedVariable", CheckSeverity.OFF); errorProneOptions.check( @@ -220,7 +223,7 @@ private static void configureErrorProneOptions( errorProneOptions.check("URLEqualsHashCode", CheckSeverity.ERROR); // Relax some checks for test code - if (errorProneOptions.isCompilingTestOnlyCode()) { + if (errorProneOptions.getCompilingTestOnlyCode().get()) { errorProneOptions.check("UnnecessaryLambda", CheckSeverity.OFF); } @@ -372,9 +375,9 @@ private static boolean isErrorProneRefactoring(Project project) { } private static boolean checkExplicitlyDisabled(ErrorProneOptions errorProneOptions, String check) { - Map checks = errorProneOptions.getChecks(); + Map checks = errorProneOptions.getChecks().get(); return checks.get(check) == CheckSeverity.OFF - || errorProneOptions.getErrorproneArgs().contains(String.format("-Xep:%s:OFF", check)); + || errorProneOptions.getErrorproneArgs().get().contains(String.format("-Xep:%s:OFF", check)); } private static final class LazyConfigurationList extends AbstractList { diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy index ec08eb4c4..55ba893f4 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineErrorProneIntegrationTest.groovy @@ -170,7 +170,7 @@ class BaselineErrorProneIntegrationTest extends AbstractPluginTest { buildFile << standardBuildFile buildFile << """ tasks.withType(JavaCompile) { - options.errorprone.errorproneArgs += ['-Xep:OptionalOrElseMethodInvocation:OFF'] + options.errorprone.disable 'OptionalOrElseMethodInvocation' } dependencies { implementation 'org.slf4j:slf4j-api:1.7.25' @@ -203,7 +203,7 @@ class BaselineErrorProneIntegrationTest extends AbstractPluginTest { def 'compileJava does not apply patches for error-prone checks that were turned OFF via #checkConfigurationMethod'() { def checkName = "Slf4jLogsafeArgs" def turnOffCheck = [ - (CheckConfigurationMethod.ARG): "options.errorprone.errorproneArgs += ['-Xep:$checkName:OFF']", + (CheckConfigurationMethod.ARG): "options.errorprone.disable '$checkName'", (CheckConfigurationMethod.DSL): """ options.errorprone { check '$checkName', net.ltgt.gradle.errorprone.CheckSeverity.OFF diff --git a/versions.lock b/versions.lock index f6c85ee27..119c2a051 100644 --- a/versions.lock +++ b/versions.lock @@ -49,7 +49,7 @@ io.dropwizard.metrics:metrics-core:3.2.6 (1 constraints: 95108ba5) junit:junit:4.13 (8 constraints: af73d634) net.bytebuddy:byte-buddy:1.10.5 (1 constraints: 410b37de) net.bytebuddy:byte-buddy-agent:1.10.5 (1 constraints: 410b37de) -net.ltgt.gradle:gradle-errorprone-plugin:0.7.1 (1 constraints: 0a050136) +net.ltgt.gradle:gradle-errorprone-plugin:1.2.1 (1 constraints: 0605f735) org.apache.commons:commons-lang3:3.9 (1 constraints: b004292c) org.apache.maven:maven-artifact:2.0.5 (3 constraints: 5032579f) org.apache.maven:maven-artifact-manager:2.0.5 (1 constraints: 310dcb20) diff --git a/versions.props b/versions.props index c4a64c92d..7e138e81f 100644 --- a/versions.props +++ b/versions.props @@ -15,24 +15,22 @@ org.immutables:* = 2.8.8 org.ow2.asm:asm = 7.3.1 # test deps +com.fasterxml.jackson.*:* = 2.11.0 +com.github.stefanbirkner:system-rules = 1.19.0 com.netflix.nebula:nebula-test = 7.8.6 +com.palantir.tokens:auth-tokens = 3.6.1 +com.palantir.tritium:tritium-registry = 0.16.10 +commons-lang:commons-lang = 2.6 junit:junit = 4.13 net.lingala.zip4j:zip4j = 1.3.2 -com.github.stefanbirkner:system-rules = 1.19.0 +net.ltgt.gradle:gradle-errorprone-plugin = 1.2.1 org.apache.commons:commons-lang3 = 3.9 -commons-lang:commons-lang = 2.6 org.assertj:assertj-core = 3.16.1 org.hamcrest:hamcrest-core = 2.2 org.junit.jupiter:* = 5.6.2 org.mockito:* = 3.3.3 -com.fasterxml.jackson.*:* = 2.11.0 -com.palantir.tokens:auth-tokens = 3.6.1 -com.palantir.tritium:tritium-registry = 0.16.10 # dependency-upgrader:OFF -# Updating to 0.8 would raise our minimum compatible version to 5.2 -net.ltgt.gradle:gradle-errorprone-plugin = 0.7.1 - # Don't upgrade, we will remove this in a future release. # Users should depend on this plugin directly such that it will get updated by excavator. com.palantir.javaformat:gradle-palantir-java-format = 0.3.9