дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
fix(run): launch a Gradle-delegated run on the project's Java toolchain (#5656)
Build and run using Gradle started the main class on Gradle's own JVM: the openideaRun JavaExec task never set javaLauncher, and before Gradle 9 JavaExec does not default to the project's toolchain. With a toolchain newer than Gradle's JVM the class failed with UnsupportedClassVersionError. On Gradle 6.7+ the task now launches on the project's Java toolchain, as the application plugin's run does; a project without a toolchain still runs on Gradle's JVM. Fixes #5594 Co-authored-by: Inf1mum <[email protected]>
Цей коміт міститься в:
1 джерело
cd3399df60
коміт
63f2f0280d
2 files changed
+12
No files matched your search
@@ -21,6 +21,11 @@ allprojects { p ->
|
||||
t.classpath = p.sourceSets.getByName(System.getProperty('openidea.run.sourceSet', 'main')).runtimeClasspath
|
||||
def main = System.getProperty('openidea.run.main')
|
||||
if (t.hasProperty('mainClass')) t.mainClass.set(main) else t.main = main
|
||||
// Gradle 6.7+: the project's Java toolchain launches it, as the application plugin's `run` does.
|
||||
if (t.hasProperty('javaLauncher')) {
|
||||
def java = p.extensions.getByType(org.gradle.api.plugins.JavaPluginExtension)
|
||||
t.javaLauncher.set(p.extensions.getByType(org.gradle.jvm.toolchain.JavaToolchainService).launcherFor(java.toolchain))
|
||||
}
|
||||
t.args(list('openidea.run.args'))
|
||||
t.jvmArgs(list('openidea.run.jvmArgs'))
|
||||
def token = System.getProperty('openidea.run.token')
|
||||
|
||||
@@ -274,6 +274,13 @@ describe("Build and run using: Gradle", () => {
|
||||
expect(RUN_SCRIPT).toContain("else p.tasks.create('openideaRun', JavaExec, configure)");
|
||||
expect(RUN_SCRIPT).toContain("import org.gradle.util.GradleVersion");
|
||||
});
|
||||
|
||||
// A toolchain newer than Gradle's JVM: on it, a class compiled for that toolchain fails to load (#5594).
|
||||
it("launches on the project's Java toolchain, as the application plugin's `run` does (#5594)", () => {
|
||||
// `javaLauncher` is Gradle 6.7+: guarded on its line, like `mainClass`.
|
||||
expect(RUN_SCRIPT).toContain("if (t.hasProperty('javaLauncher'))");
|
||||
expect(RUN_SCRIPT).toContain("JavaToolchainService).launcherFor(");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Gradle test runs", () => {
|
||||
|
||||
Reference in new issue
Заблокувати користувача