Skip to content

Commit

Permalink
feat: attempt to support Gradle 8
Browse files Browse the repository at this point in the history
This is incomplete and does not fully work yet. We might have to get rid of the lazy configuration of `forkOptions.executable`. See gradle/gradle#23990 (comment)

See #9
  • Loading branch information
TheMrMilchmann committed Mar 2, 2023
1 parent aea6681 commit 2bf6dc0
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -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<Project> {

Expand All @@ -49,6 +50,8 @@ public class ECJPlugin : Plugin<Project> {
/* 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@{
Expand Down Expand Up @@ -77,11 +80,13 @@ public class ECJPlugin : Plugin<Project> {
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))
Expand Down

0 comments on commit 2bf6dc0

Please sign in to comment.