From 2bf6dc0258a723ed500392eca8c051bd07dd3cd6 Mon Sep 17 00:00:00 2001 From: Leon Linhart Date: Thu, 2 Mar 2023 12:33:11 +0100 Subject: [PATCH] feat: attempt to support Gradle 8 This is incomplete and does not fully work yet. We might have to get rid of the lazy configuration of `forkOptions.executable`. See https://github.com/gradle/gradle/issues/23990#issuecomment-1450590774 See #9 --- .../themrmilchmann/gradle/ecj/plugins/ECJPlugin.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/io/github/themrmilchmann/gradle/ecj/plugins/ECJPlugin.kt b/src/main/kotlin/io/github/themrmilchmann/gradle/ecj/plugins/ECJPlugin.kt index ca063e4..f972f66 100644 --- a/src/main/kotlin/io/github/themrmilchmann/gradle/ecj/plugins/ECJPlugin.kt +++ b/src/main/kotlin/io/github/themrmilchmann/gradle/ecj/plugins/ECJPlugin.kt @@ -30,6 +30,7 @@ import org.gradle.api.tasks.Classpath import org.gradle.api.tasks.compile.* import org.gradle.jvm.toolchain.* import org.gradle.process.CommandLineArgumentProvider +import org.gradle.util.GradleVersion public class ECJPlugin : Plugin { @@ -49,6 +50,8 @@ public class ECJPlugin : Plugin { /* The version required to run ECJ. */ const val REQUIRED_JAVA_VERSION = 11 + private val GRADLE_8_0 = GradleVersion.version("8.0") + } override fun apply(target: Project): Unit = applyTo(target) project@{ @@ -77,11 +80,13 @@ public class ECJPlugin : Plugin { val javaToolchains = extensions.getByType(JavaToolchainService::class.java) tasks.withType(JavaCompile::class.java).configureEach { - /* Overwrite the javaCompiler to make sure that it is not inferred from the toolchain. */ - javaCompiler.set(provider { null }) + if (GradleVersion.current() < GRADLE_8_0) { + /* Overwrite the javaCompiler to make sure that it is not inferred from the toolchain. */ + javaCompiler.set(provider { null }) + } /* ECJ does not support generating JNI headers. Make sure the property is not used. */ - options.headerOutputDirectory.set(this@project.provider { null }) + options.headerOutputDirectory.set(provider { null }) options.isFork = true options.forkOptions.jvmArgumentProviders.add(ECJCommandLineArgumentProvider(ecjConfiguration))