From f4f9971daf39148cf351528b843a59d7c1296ca6 Mon Sep 17 00:00:00 2001 From: Sorokin Maksim Date: Sat, 13 Aug 2022 01:22:08 +0300 Subject: [PATCH] fixes #128 - throw away redundant shenanigans with classpath & module path --- build.gradle | 2 +- .../gradle/tasks/NativeRunAgentTask.java | 34 ------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/build.gradle b/build.gradle index 0a7d5b4..c9513b9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java-gradle-plugin' - id 'com.github.hierynomus.license' version '0.15.0' + id 'com.github.hierynomus.license' version '0.16.1' id 'com.gradle.plugin-publish' version '1.0.0-rc-2' id 'com.github.ben-manes.versions' version '0.27.0' id 'maven-publish' diff --git a/src/main/java/com/gluonhq/gradle/tasks/NativeRunAgentTask.java b/src/main/java/com/gluonhq/gradle/tasks/NativeRunAgentTask.java index 8001ab6..1b4023e 100644 --- a/src/main/java/com/gluonhq/gradle/tasks/NativeRunAgentTask.java +++ b/src/main/java/com/gluonhq/gradle/tasks/NativeRunAgentTask.java @@ -50,10 +50,8 @@ import java.io.OutputStreamWriter; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.TreeSet; public class NativeRunAgentTask extends NativeBaseTask { @@ -118,39 +116,7 @@ public void action() { throw new GradleException("Run task not found."); } - JavaFXOptions javaFXOptions = project.getExtensions().getByType(JavaFXOptions.class); - var definedJavaFXModuleNames = new TreeSet<>(javaFXOptions.getModules()); - if (definedJavaFXModuleNames.isEmpty()) { - throw new GradleException("No JavaFX modules found."); - } - final FileCollection classpathWithoutJavaFXJars = execTask.getClasspath().filter( - jar -> Arrays.stream(JavaFXModule.values()).noneMatch(javaFXModule -> - jar.getName().contains(javaFXModule.getArtifactName())) - ); - final FileCollection javaFXPlatformJars = execTask.getClasspath().filter(jar -> - isJavaFXJar(jar, javaFXOptions.getPlatform())); - - // Remove all JavaFX jars from classpath - execTask.setClasspath(classpathWithoutJavaFXJars); - - // Define JVM args for command line - var javaFXModuleJvmArgs = List.of("--module-path", javaFXPlatformJars.getAsPath()); - var jvmArgs = new ArrayList<>(javaFXModuleJvmArgs); - jvmArgs.add("--add-modules"); - jvmArgs.add(String.join(",", definedJavaFXModuleNames)); - if (GradleVersion.current().compareTo(GradleVersion.version("6.6")) < 0) { - // Include classpath as JVM arg for Gradle versions lower than 6.6 - jvmArgs.add("-cp"); - jvmArgs.add(classpathWithoutJavaFXJars.getAsPath()); - } - - // set java_home - execTask.executable(Path.of(graalVMHome.toString(), "bin", "java").toString()); - - // set jvmargs execTask.getJvmArgs().add(AGENTLIB_NATIVE_IMAGE_AGENT_STRING); - execTask.getJvmArgs().addAll(jvmArgs); - // run execTask.exec(); } catch (Exception e) {