Skip to content

Commit

Permalink
Merge pull request #36793 from aloubyansky/quarkusRun-jvmArgs
Browse files Browse the repository at this point in the history
Add jvmArgs option to Quarkus Gradle plugin task quarkusRun
  • Loading branch information
aloubyansky authored Oct 31, 2023
2 parents 3149ece + 48f901c commit 7de523b
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,6 +39,7 @@
public abstract class QuarkusRun extends QuarkusBuildTask {
private final Property<File> workingDirectory;
private final SourceSet mainSourceSet;
private final ListProperty<String> jvmArgs;

@Inject
public QuarkusRun() {
Expand All @@ -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);
}

/**
Expand All @@ -75,6 +81,22 @@ public void setWorkingDir(String workingDir) {
workingDirectory.set(getProject().file(workingDir));
}

@Input
public ListProperty<String> getJvmArguments() {
return jvmArgs;
}

@Internal
public List<String> getJvmArgs() {
return jvmArgs.get();
}

@SuppressWarnings("unused")
@Option(description = "Set JVM arguments", option = "jvm-args")
public void setJvmArgs(List<String> jvmArgs) {
this.jvmArgs.set(jvmArgs);
}

@TaskAction
public void runQuarkus() {
ApplicationModel appModel = resolveAppModelForBuild();
Expand Down Expand Up @@ -122,6 +144,10 @@ public void accept(Map<String, List> cmds) {
throw new RuntimeException("Should never reach this!");
}
List<String> args = (List<String>) 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();
Expand Down

0 comments on commit 7de523b

Please sign in to comment.