diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java index c4fb864085c84..ea37bcb6875d2 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java @@ -14,15 +14,18 @@ import org.gradle.api.GradleException; import org.gradle.api.file.FileCollection; import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.ListProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.Internal; import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.PathSensitive; import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.TaskAction; +import org.gradle.api.tasks.options.Option; import io.quarkus.bootstrap.BootstrapException; import io.quarkus.bootstrap.app.AugmentAction; @@ -36,6 +39,7 @@ public abstract class QuarkusRun extends QuarkusBuildTask { private final Property workingDirectory; private final SourceSet mainSourceSet; + private final ListProperty jvmArgs; @Inject public QuarkusRun() { @@ -50,6 +54,8 @@ public QuarkusRun(String description) { workingDirectory = objectFactory.property(File.class); workingDirectory.convention(getProject().provider(() -> QuarkusPluginExtension.getLastFile(getCompilationOutput()))); + + jvmArgs = objectFactory.listProperty(String.class); } /** @@ -75,6 +81,22 @@ public void setWorkingDir(String workingDir) { workingDirectory.set(getProject().file(workingDir)); } + @Input + public ListProperty getJvmArguments() { + return jvmArgs; + } + + @Internal + public List getJvmArgs() { + return jvmArgs.get(); + } + + @SuppressWarnings("unused") + @Option(description = "Set JVM arguments", option = "jvm-args") + public void setJvmArgs(List jvmArgs) { + this.jvmArgs.set(jvmArgs); + } + @TaskAction public void runQuarkus() { ApplicationModel appModel = resolveAppModelForBuild(); @@ -122,6 +144,10 @@ public void accept(Map cmds) { throw new RuntimeException("Should never reach this!"); } List args = (List) cmd.get(0); + if (getJvmArguments().isPresent() && !getJvmArguments().get().isEmpty()) { + args.addAll(1, getJvmArgs()); + } + getProject().getLogger().info("Executing \"" + String.join(" ", args) + "\""); Path wd = (Path) cmd.get(1); File wdir = wd != null ? wd.toFile() : workingDirectory.get();