From 5331692cac1f69ece5a20236fdc4a124a957e5fd Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Tue, 21 Nov 2023 22:50:42 +0100 Subject: [PATCH] Allow for multiple run types --- .../gradle/common/runs/run/RunImpl.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java b/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java index bca0a8bc8..465d4ec15 100644 --- a/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java +++ b/common/src/main/java/net/neoforged/gradle/common/runs/run/RunImpl.java @@ -30,7 +30,7 @@ public abstract class RunImpl implements ConfigurableDSLElement, Run { private MapProperty environmentVariables; private ListProperty programArguments; private MapProperty systemProperties; - private final Property runType; + private final ListProperty runTypes; private final Set> dependencies = Sets.newHashSet(); @@ -43,7 +43,7 @@ public RunImpl(final Project project, final String name) { this.environmentVariables = this.project.getObjects().mapProperty(String.class, String.class); this.programArguments = this.project.getObjects().listProperty(String.class); this.systemProperties = this.project.getObjects().mapProperty(String.class, String.class); - this.runType = this.project.getObjects().property(RunType.class); + this.runTypes = this.project.getObjects().listProperty(RunType.class); getIsSingleInstance().convention(true); getIsClient().convention(false); @@ -118,29 +118,30 @@ public Set> getTaskDependencies() { @Override public final void configure() { - if (getConfigureFromTypeWithName().get() && !runType.isPresent()) { - runType.set(getRunTypeProviderByName(name)); + if (getConfigureFromTypeWithName().get()) { + configureInternally(getRunTypeProviderByName(name).get()); } - if (runType.isPresent()) { - configureInternally(runType.get()); + for (RunType runType : runTypes.get()) { + configureInternally(runType); } } @Override public final void configure(final @NotNull String name) { - runType.set(getRunTypeProviderByName(name)); + getConfigureFromTypeWithName().set(false); // Don't re-configure + runTypes.add(getRunTypeProviderByName(name)); } @Override public final void configure(final @NotNull RunType runType) { getConfigureFromTypeWithName().set(false); // Don't re-configure - this.runType.set(runType); + this.runTypes.add(runType); } @Override public void configure(@NotNull Provider typeProvider) { - this.runType.set(typeProvider); + this.runTypes.add(typeProvider); } @SafeVarargs @@ -150,6 +151,7 @@ public final void dependsOn(TaskProvider... tasks) { } public void configureInternally(final @NotNull RunType spec) { + project.getLogger().debug("Configuring run {} with run type {}", name, spec.getName()); getEnvironmentVariables().putAll(spec.getEnvironmentVariables()); getMainClass().convention(spec.getMainClass()); getProgramArguments().addAll(spec.getArguments());