Skip to content

Commit

Permalink
Merge pull request #28410 from glefloch/fix/gradle-add-module
Browse files Browse the repository at this point in the history
Add properties to quarkusDev task to set add-module clause and open Java lang module
  • Loading branch information
aloubyansky authored Oct 6, 2022
2 parents 97324a1 + 64c85f0 commit f9dd29f
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public class QuarkusDev extends QuarkusTask {
private final Property<Boolean> shouldPropagateJavaCompilerArgs;
private final ListProperty<String> args;
private final ListProperty<String> jvmArgs;

private final Property<Boolean> openJavaLang;
private final ListProperty<String> modules;
private final ListProperty<String> compilerArgs;

private final Set<File> filesIncludedInClasspath = new HashSet<>();
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -219,6 +225,26 @@ public ListProperty<String> getArguments() {
return args;
}

@Option(description = "Modules to add to the application", option = "modules")
public void setModules(List<String> modules) {
this.modules.set(modules);
}

@Input
public ListProperty<String> 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<Boolean> getOpenJavaLang() {
return openJavaLang;
}

@SuppressWarnings("unused")
@Internal
public List<String> getArgs() {
Expand Down Expand Up @@ -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<String, ?> e : project.getProperties().entrySet()) {
if (e.getValue() instanceof String) {
builder.buildSystemProperty(e.getKey(), e.getValue().toString());
Expand Down

0 comments on commit f9dd29f

Please sign in to comment.