mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Merge remote-tracking branch 'FabricMC/dev/0.6' into 0.6-merge
# Conflicts: # src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java # src/main/java/net/fabricmc/loom/configuration/ide/RunConfigSettings.java # src/main/java/net/fabricmc/loom/task/LoomTasks.java
This commit is contained in:
@@ -32,6 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -122,7 +123,7 @@ public class RunConfig {
|
||||
return module;
|
||||
}
|
||||
|
||||
private static void populate(Project project, LoomGradleExtension extension, RunConfig runConfig, String mode) {
|
||||
private static void populate(Project project, LoomGradleExtension extension, RunConfig runConfig, String environment) {
|
||||
runConfig.configName += extension.isRootProject() ? "" : " (" + project.getPath() + ")";
|
||||
runConfig.eclipseProjectName = project.getExtensions().getByType(EclipseModel.class).getProject().getName();
|
||||
runConfig.vscodeProjectName = extension.isRootProject() ? "" : project.getPath();
|
||||
@@ -131,10 +132,10 @@ public class RunConfig {
|
||||
|
||||
if ("launchwrapper".equals(extension.getLoaderLaunchMethod())) {
|
||||
runConfig.mainClass = "net.minecraft.launchwrapper.Launch"; // TODO What about custom tweakers for run configs?
|
||||
runConfig.programArgs += "--tweakClass " + ("client".equals(mode) ? Constants.LaunchWrapper.DEFAULT_FABRIC_CLIENT_TWEAKER : Constants.LaunchWrapper.DEFAULT_FABRIC_SERVER_TWEAKER);
|
||||
runConfig.programArgs += "--tweakClass " + ("client".equals(environment) ? Constants.LaunchWrapper.DEFAULT_FABRIC_CLIENT_TWEAKER : Constants.LaunchWrapper.DEFAULT_FABRIC_SERVER_TWEAKER);
|
||||
} else {
|
||||
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
|
||||
runConfig.vmArgs = "-Dfabric.dli.config=" + encodeEscaped(extension.getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + mode.toLowerCase();
|
||||
runConfig.vmArgs = "-Dfabric.dli.config=" + encodeEscaped(extension.getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + environment.toLowerCase();
|
||||
}
|
||||
|
||||
if (extension.isForge()) {
|
||||
@@ -159,7 +160,7 @@ public class RunConfig {
|
||||
JsonObject installerJson = extension.getInstallerJson();
|
||||
|
||||
if (installerJson != null) {
|
||||
List<String> sideKeys = ImmutableList.of(mode, "common");
|
||||
List<String> sideKeys = ImmutableList.of(environment, "common");
|
||||
|
||||
// copy launchwrapper tweakers
|
||||
if (installerJson.has("launchwrapper")) {
|
||||
@@ -199,7 +200,7 @@ public class RunConfig {
|
||||
String name = settings.getName();
|
||||
|
||||
String configName = settings.getConfigName();
|
||||
String mode = settings.getMode();
|
||||
String environment = settings.getEnvironment();
|
||||
SourceSet sourceSet = settings.getSource(project);
|
||||
|
||||
String defaultMain = settings.getDefaultMainClass();
|
||||
@@ -219,9 +220,7 @@ public class RunConfig {
|
||||
configName += "Minecraft " + capitalizeCamelCaseName(name);
|
||||
}
|
||||
|
||||
if (mode == null) {
|
||||
mode = name;
|
||||
}
|
||||
Objects.requireNonNull(environment, "No environment set for run config");
|
||||
|
||||
String runDir = settings.getRunDir();
|
||||
|
||||
@@ -231,7 +230,7 @@ public class RunConfig {
|
||||
|
||||
RunConfig runConfig = new RunConfig();
|
||||
runConfig.configName = configName;
|
||||
populate(project, extension, runConfig, mode);
|
||||
populate(project, extension, runConfig, environment);
|
||||
runConfig.ideaModuleName = getIdeaModuleName(project, sourceSet);
|
||||
runConfig.runDirIdeaUrl = "file://$PROJECT_DIR$/" + runDir;
|
||||
runConfig.runDir = runDir;
|
||||
@@ -245,7 +244,7 @@ public class RunConfig {
|
||||
runConfig.vmArgs += " " + vmArg;
|
||||
}
|
||||
|
||||
runConfig.vmArgs += " -Dfabric.dli.main=" + getMainClass(mode, extension, defaultMain);
|
||||
runConfig.vmArgs += " -Dfabric.dli.main=" + getMainClass(environment, extension, defaultMain);
|
||||
|
||||
// Remove unnecessary leading/trailing whitespaces we might have generated
|
||||
runConfig.programArgs = runConfig.programArgs.trim();
|
||||
|
||||
@@ -58,9 +58,9 @@ public final class RunConfigSettings implements Named {
|
||||
private final List<String> programArgs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The mode to run, which is the name of the run config in {@code fabric_installer.[method].json}.
|
||||
* The environment (or side) to run, usually client or server.
|
||||
*/
|
||||
private String mode;
|
||||
private String environment;
|
||||
|
||||
/**
|
||||
* The full name of the run configuration, i.e. 'Minecraft Client'.
|
||||
@@ -100,7 +100,6 @@ public final class RunConfigSettings implements Named {
|
||||
this.project = project;
|
||||
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
||||
mode(baseName);
|
||||
source("main");
|
||||
runDir("run");
|
||||
}
|
||||
@@ -126,12 +125,12 @@ public final class RunConfigSettings implements Named {
|
||||
return programArgs;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
public String getEnvironment() {
|
||||
return environment;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
public void setEnvironment(String environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public String getConfigName() {
|
||||
@@ -170,8 +169,8 @@ public final class RunConfigSettings implements Named {
|
||||
this.source = sourceFn;
|
||||
}
|
||||
|
||||
public void mode(String mode) {
|
||||
setMode(mode);
|
||||
public void environment(String environment) {
|
||||
setEnvironment(environment);
|
||||
}
|
||||
|
||||
public void name(String name) {
|
||||
@@ -255,7 +254,7 @@ public final class RunConfigSettings implements Named {
|
||||
*/
|
||||
public void client() {
|
||||
startFirstThread();
|
||||
mode("client");
|
||||
environment("client");
|
||||
defaultMainClass(getExtension().isForge() ? Constants.ForgeUserDev.LAUNCH_TESTING : Constants.Knot.KNOT_CLIENT);
|
||||
}
|
||||
|
||||
@@ -264,7 +263,7 @@ public final class RunConfigSettings implements Named {
|
||||
*/
|
||||
public void server() {
|
||||
programArg("nogui");
|
||||
mode("server");
|
||||
environment("server");
|
||||
defaultMainClass(getExtension().isForge() ? Constants.ForgeUserDev.LAUNCH_TESTING : Constants.Knot.KNOT_SERVER);
|
||||
}
|
||||
|
||||
@@ -283,7 +282,7 @@ public final class RunConfigSettings implements Named {
|
||||
vmArgs.addAll(0, parent.vmArgs);
|
||||
programArgs.addAll(0, parent.programArgs);
|
||||
|
||||
mode = parent.mode;
|
||||
environment = parent.environment;
|
||||
name = parent.name;
|
||||
defaultMainClass = parent.defaultMainClass;
|
||||
source = parent.source;
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.tasks.JavaExec;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
@@ -46,7 +47,7 @@ public abstract class AbstractRunTask extends JavaExec {
|
||||
setGroup("fabric");
|
||||
this.configProvider = config;
|
||||
|
||||
classpath(getProject().getConfigurations().getByName("runtimeClasspath"));
|
||||
setClasspath(getProject().getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
|
||||
classpath(this.getProject().getExtensions().getByType(LoomGradleExtension.class).getUnmappedModCollection());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.tasks.TaskContainer;
|
||||
|
||||
@@ -85,26 +86,24 @@ public final class LoomTasks {
|
||||
private static void registerRunTasks(TaskContainer tasks, Project project) {
|
||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||
|
||||
Preconditions.checkArgument(extension.getRuns().size() == 0, "Run configurations must not be registered before loom");
|
||||
|
||||
extension.getRuns().whenObjectAdded(config -> {
|
||||
String configName = config.getName();
|
||||
String taskName = "run" + configName.substring(0, 1).toUpperCase() + configName.substring(1);
|
||||
|
||||
tasks.register(taskName, RunGameTask.class, config).configure(t -> {
|
||||
t.setDescription("Starts the '" + config.getConfigName() + "' run configuration");
|
||||
t.setGroup("fabric");
|
||||
|
||||
if (config.getEnvironment().equals("client")) {
|
||||
t.dependsOn("downloadAssets");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
extension.getRuns().create("client", RunConfigSettings::client);
|
||||
extension.getRuns().create("server", RunConfigSettings::server);
|
||||
|
||||
project.afterEvaluate(p -> {
|
||||
if (extension.isDataGenEnabled()) {
|
||||
extension.getRuns().create("data", RunConfigSettings::data);
|
||||
}
|
||||
});
|
||||
|
||||
project.afterEvaluate(p -> {
|
||||
for (RunConfigSettings config : extension.getRuns()) {
|
||||
String configName = config.getName();
|
||||
String taskName = "run" + configName.substring(0, 1).toUpperCase() + configName.substring(1);
|
||||
|
||||
tasks.register(taskName, RunGameTask.class, config).configure(t -> {
|
||||
t.setDescription("Starts the '" + config.getConfigName() + "' run configuration");
|
||||
t.setGroup("fabric");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void registerDecompileTasks(TaskContainer tasks, Project project) {
|
||||
|
||||
Reference in New Issue
Block a user