Skip to content

Ant doesn't respect Gradle toolchain version #18

@noschiff

Description

@noschiff

Sherrloc is imported to our Gradle build via ant.importBuild, which allows us to configure Gradle targets to relate to ant tasks:

SCIF/build.gradle

Lines 18 to 20 in f7105a0

ant.importBuild("sherrloc/GenErrorDiagnostic/build.xml") {
antTargetName -> "slc-" + antTargetName
}

SCIF/build.gradle

Lines 59 to 61 in f7105a0

compileJava.configure {
dependsOn("slc-jar")
}

We configure Gradle to use the Java 21 toolchain, which means that Gradle will use Java 21 for its tasks, like running and building the application:

SCIF/build.gradle

Lines 12 to 16 in f7105a0

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

When running or building the project with the Gradle wrapper, Gradle will thus output compiled class files for Java 21 and use the Java 21 runtime to run the application. Unfortunately, it seems Ant will compile using the system's global Java version. My java is openjdk 23.0.1 2024-10-15, so sherrloc is compiled with class version 67 (Java 23).

Exception in thread "main" java.lang.UnsupportedClassVersionError: sherrloc/constraint/parse/parser has been compiled by a more recent version of the Java Runtime (class file version 67.0), this version of the Java Runtime only recognizes class file versions up to 65.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions