Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jvmArgs option to Quarkus Gradle plugin task quarkusRun #36793

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading