-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This newer Eclipse release requires Java 17 or better. However, we still prefer to keep most of WALA compatible with Java 11. Therefore, this Eclipse upgrade adds nontrivial build infrastructure to let us use a newer Java release only where Eclipse dependencies require it. A new `com.ibm.wala.jdk-version` property in `gradle.properties` allows setting the default Java version used throughout WALA. If this property is set to 17 or higher, then that same version is used both for Eclipse-dependent and Eclipse-independent WALA components. However, if this property is set to 16 or earlier, then it is only used for WALA's Eclipse-independent components; the Eclipse-dependent components will override this and use Java 17 instead. In a default configuration, most of WALA will be compiled with (and for) Java 11, with the Eclipse-dependent components using Java 17 instead. Resolves #1354.
- Loading branch information
Showing
10 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
build-logic/src/main/kotlin/com/ibm/wala/gradle/EclipseCompatibleJavaExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.ibm.wala.gradle | ||
|
||
import javax.inject.Inject | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.jvm.toolchain.JavaLauncher | ||
import org.gradle.jvm.toolchain.JavaToolchainService | ||
import org.gradle.kotlin.dsl.the | ||
|
||
/** | ||
* The earliest Java version that is compatible with bytecode used in Eclipse dependencies. | ||
* | ||
* When changing `eclipse` in the `versions` section of `gradle/libs.versions.toml`, consider | ||
* whether this value needs to be changed as well. | ||
*/ | ||
private const val MINIMUM_ECLIPSE_COMPATIBLE_JAVA_VERSION = 17 | ||
|
||
/** | ||
* A Gradle [Project] extension providing details about to Eclipse-compatible Java toolchains. | ||
* | ||
* @constructor Creates an extension instance that will be attached to the given [project]. | ||
* @property project The project to which this extension instance is attached. | ||
* @property languageVersion A Java language version that is compatible with WALA's Eclipse | ||
* dependencies. | ||
* @property launcher Provides a Java JVM launcher (i.e., `java` command) that is compatible with | ||
* WALA's Eclipse dependencies. | ||
*/ | ||
open class EclipseCompatibleJavaExtension @Inject constructor(private val project: Project) { | ||
|
||
val languageVersion: JavaLanguageVersion by lazy { | ||
project.run { | ||
val projectVersion = the<JavaPluginExtension>().toolchain.languageVersion.get() | ||
val minimumVersion = JavaLanguageVersion.of(MINIMUM_ECLIPSE_COMPATIBLE_JAVA_VERSION) | ||
if (projectVersion.canCompileOrRun(minimumVersion)) projectVersion else minimumVersion | ||
} | ||
} | ||
|
||
val launcher: Provider<JavaLauncher> by lazy { | ||
project.the<JavaToolchainService>().launcherFor { | ||
languageVersion.set(this@EclipseCompatibleJavaExtension.languageVersion) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
build-logic/src/main/kotlin/com/ibm/wala/gradle/eclipse-compatible-java.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ibm.wala.gradle | ||
|
||
plugins { java } | ||
|
||
// Make Eclipse-compatible Java information available as `project.eclipseCompatibleJava`. | ||
extensions.create<EclipseCompatibleJavaExtension>("eclipseCompatibleJava") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters