diff --git a/README.md b/README.md index 208ff67..496aee9 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,17 @@ This plugin configures `JavaCompile` tasks to use [Error Prone]. ## Requirements > [!IMPORTANT] -> This plugin requires using at least Gradle 6.8 and JDK 9 (for compilation; it's OK to use JDK 8 to run Gradle as long as compilations use at least JDK 9 through [Gradle Java Toolchains][gradle-toolchains]). +> This plugin requires using at least Gradle 6.8 and JDK 11 (for compilation; it's OK to use JDK 8 to run Gradle as long as compilations use at least JDK 11 through [Gradle Java Toolchains][gradle-toolchains]). The exact minimum required version of the JDK depends on the version of Error Prone being used (independently of the version of this plugin); there's no forward compatibility guarantee though so older versions of Error Prone aren't necessarily compatible with newer versions of the JDK. | Error Prone version | Minimum JDK version | | :------------------: | :-----------------: | -| Up to 2.10 | 9 | -| From 2.10 up to 2.31 | 11 | +| Up to 2.31 | 11 | | Starting from 2.32 | 17 | -You can still compile down to Java 8 bytecode though, by using JDK 9+ support for `--release 8` (which you can configure with Gradle using [`options.release`][CompileOptions.release]), or with `-source` / `-target` / `-bootclasspath` (configured with Gradle using [`sourceCompatibility`][JavaCompile.sourceCompatibility] / [`targetCompatibility`][JavaCompile.targetCompatibility] / [`options.bootstrapClasspath`][CompileOptions.bootstrapClasspath]). +You can still compile down to a Java version bytecode though, by using javac's support for `--release` (which you can configure with Gradle using [`options.release`][CompileOptions.release]), or with `-source` / `-target` / `-bootclasspath` (configured with Gradle using [`sourceCompatibility`][JavaCompile.sourceCompatibility] / [`targetCompatibility`][JavaCompile.targetCompatibility] / [`options.bootstrapClasspath`][CompileOptions.bootstrapClasspath]). ```kotlin tasks.withType().configureEach { diff --git a/src/main/kotlin/net/ltgt/gradle/errorprone/ErrorPronePlugin.kt b/src/main/kotlin/net/ltgt/gradle/errorprone/ErrorPronePlugin.kt index 8ad70d5..0e3b463 100644 --- a/src/main/kotlin/net/ltgt/gradle/errorprone/ErrorPronePlugin.kt +++ b/src/main/kotlin/net/ltgt/gradle/errorprone/ErrorPronePlugin.kt @@ -31,7 +31,7 @@ class ErrorPronePlugin @Inject constructor( const val CONFIGURATION_NAME = "errorprone" - internal const val TOO_OLD_TOOLCHAIN_ERROR_MESSAGE = "Must not enable ErrorProne when compiling with JDK < 9" + internal const val TOO_OLD_TOOLCHAIN_ERROR_MESSAGE = "Must not enable ErrorProne when compiling with JDK < 11" private val HAS_JVM_ARGUMENT_PROVIDERS = GradleVersion.current() >= GradleVersion.version("7.1") @@ -112,7 +112,7 @@ class ErrorPronePlugin @Inject constructor( doFirst("Configure forking for errorprone") { if (!errorproneOptions.isEnabled.getOrElse(false)) return@doFirst jvmArgumentProvider.compilerVersion?.let { - if (it < JavaVersion.VERSION_1_9) throw UnsupportedOperationException(TOO_OLD_TOOLCHAIN_ERROR_MESSAGE) + if (it < JavaVersion.VERSION_11) throw UnsupportedOperationException(TOO_OLD_TOOLCHAIN_ERROR_MESSAGE) if ((it == JavaVersion.current() && CURRENT_JVM_NEEDS_FORKING) && !options.isFork) options.isFork = true } } @@ -123,7 +123,7 @@ class ErrorPronePlugin @Inject constructor( project.configurations[annotationProcessorConfigurationName].extendsFrom(errorproneConfiguration) project.tasks.named(compileJavaTaskName) { options.errorprone { - isEnabled.convention(javaCompiler.map { it.metadata.languageVersion.asInt() >= 9 }.orElse(true)) + isEnabled.convention(javaCompiler.map { it.metadata.languageVersion.asInt() >= 11 }.orElse(true)) isCompilingTestOnlyCode.convention(this@configureEach.name.matches(TEST_SOURCE_SET_NAME_REGEX)) } } @@ -150,7 +150,7 @@ internal class ErrorProneJvmArgumentProvider( override fun asArguments(): Iterable = when { !errorproneOptions.isEnabled.getOrElse(false) -> emptyList() compilerVersion == null -> emptyList() - compilerVersion!! >= JavaVersion.VERSION_1_9 -> ErrorPronePlugin.JVM_ARGS_STRONG_ENCAPSULATION + compilerVersion!! >= JavaVersion.VERSION_11 -> ErrorPronePlugin.JVM_ARGS_STRONG_ENCAPSULATION else -> emptyList() } } @@ -170,7 +170,7 @@ internal class ErrorProneCompilerArgumentProvider( override fun asArguments(): Iterable { return when { - errorproneOptions.isEnabled.getOrElse(false) -> listOf("-Xplugin:ErrorProne $errorproneOptions", "-XDcompilePolicy=simple", "-XDshould-stop.ifError=FLOW") + errorproneOptions.isEnabled.getOrElse(false) -> listOf("-Xplugin:ErrorProne $errorproneOptions", "-XDcompilePolicy=simple", "--should-stop=ifError=FLOW") else -> emptyList() } }