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))