From 64c85f0f981b1226a9c3efe33635aa3a64bf605d Mon Sep 17 00:00:00 2001 From: glefloch Date: Wed, 5 Oct 2022 21:31:42 +0200 Subject: [PATCH] Add properties to quarkusDev task to set add-module clause and open java lang module --- .../io/quarkus/gradle/tasks/QuarkusDev.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index e2ac668786403..e248cfc79febd 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -87,6 +87,9 @@ public class QuarkusDev extends QuarkusTask { private final Property shouldPropagateJavaCompilerArgs; private final ListProperty args; private final ListProperty jvmArgs; + + private final Property openJavaLang; + private final ListProperty modules; private final ListProperty compilerArgs; private final Set filesIncludedInClasspath = new HashSet<>(); @@ -120,6 +123,9 @@ public QuarkusDev( args = objectFactory.listProperty(String.class); compilerArgs = objectFactory.listProperty(String.class); jvmArgs = objectFactory.listProperty(String.class); + openJavaLang = objectFactory.property(Boolean.class); + openJavaLang.convention(false); + modules = objectFactory.listProperty(String.class); } /** @@ -219,6 +225,26 @@ public ListProperty getArguments() { return args; } + @Option(description = "Modules to add to the application", option = "modules") + public void setModules(List modules) { + this.modules.set(modules); + } + + @Input + public ListProperty getModules() { + return modules; + } + + @Option(description = "Open Java Lang module", option = "open-lang-package") + public void setOpenJavaLang(Boolean openJavaLang) { + this.openJavaLang.set(openJavaLang); + } + + @Input + public Property getOpenJavaLang() { + return openJavaLang; + } + @SuppressWarnings("unused") @Internal public List getArgs() { @@ -355,6 +381,17 @@ private QuarkusDevModeLauncher newLauncher() throws Exception { builder.jvmArgs(getJvmArgs()); } + if (getOpenJavaLang().isPresent() && getOpenJavaLang().get()) { + builder.jvmArgs("--add-opens"); + builder.jvmArgs("java.base/java.lang=ALL-UNNAMED"); + } + + if (getModules().isPresent() && !getModules().get().isEmpty()) { + String mods = String.join(",", getModules().get()); + builder.jvmArgs("--add-modules"); + builder.jvmArgs(mods); + } + for (Map.Entry e : project.getProperties().entrySet()) { if (e.getValue() instanceof String) { builder.buildSystemProperty(e.getKey(), e.getValue().toString());