Generate IDE run configs on a per config basis. Allows for much finer grain control over what run configs are generated.

Defaults to generate all run configs on the root project.
dev/0.11
modmuss50 2021-02-11 18:50:25 +00:00
parent 6b481fbcd6
commit 24c166fc79
7 changed files with 33 additions and 5 deletions

View File

@ -60,7 +60,6 @@ public class LoomGradleExtension {
public String refmapName;
public String loaderLaunchMethod;
public boolean remapMod = true;
public boolean autoGenIDERuns;
public String customManifest = null;
public File accessWidener = null;
public Function<String, Object> intermediaryUrl = mcVer -> "https://maven.fabricmc.net/net/fabricmc/intermediary/" + mcVer + "/intermediary-" + mcVer + "-v2.jar";
@ -115,7 +114,6 @@ public class LoomGradleExtension {
public LoomGradleExtension(Project project) {
this.project = project;
this.autoGenIDERuns = isRootProject();
this.unmappedMods = project.files();
this.runConfigs = project.container(RunConfigSettings.class,
baseName -> new RunConfigSettings(project, baseName));

View File

@ -168,9 +168,7 @@ public final class CompileConfiguration {
project1.getTasks().getByName("eclipse").finalizedBy(project1.getTasks().getByName("genEclipseRuns"));
project1.getTasks().getByName("cleanEclipse").finalizedBy(project1.getTasks().getByName("cleanEclipseRuns"));
if (extension.autoGenIDERuns) {
SetupIntelijRunConfigs.setup(project1);
}
// Enables the default mod remapper
if (extension.remapMod) {

View File

@ -92,6 +92,13 @@ public final class RunConfigSettings implements Named {
*/
private final String baseName;
/**
* When true a run configuration file will be generated for IDE's.
*
* <p>By default only run configs on the root project will be generated.
*/
private boolean generateIDEConfig;
private final Project project;
private final LoomGradleExtension extension;
@ -99,6 +106,7 @@ public final class RunConfigSettings implements Named {
this.baseName = baseName;
this.project = project;
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
this.generateIDEConfig = extension.isRootProject();
source("main");
runDir("run");
@ -232,6 +240,10 @@ public final class RunConfigSettings implements Named {
});
}
public void generateIDEConfig(boolean generateIDEConfig) {
this.generateIDEConfig = generateIDEConfig;
}
/**
* Add the {@code -XstartOnFirstThread} JVM argument when on OSX.
*/
@ -287,4 +299,8 @@ public final class RunConfigSettings implements Named {
file.mkdir();
}
}
public boolean shouldGenerateIDEConfig() {
return generateIDEConfig;
}
}

View File

@ -72,6 +72,10 @@ public class SetupIntelijRunConfigs {
}
for (RunConfigSettings settings : extension.getRunConfigs()) {
if (!settings.shouldGenerateIDEConfig()) {
continue;
}
RunConfig config = RunConfig.runConfig(project, settings);
String name = config.configName.replaceAll("[^a-zA-Z0-9$_]", "_");

View File

@ -43,6 +43,10 @@ public class GenEclipseRunsTask extends AbstractLoomTask {
LoomGradleExtension extension = getExtension();
for (RunConfigSettings settings : extension.getRunConfigs()) {
if (!settings.shouldGenerateIDEConfig()) {
continue;
}
String name = settings.getName();
File configs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_" + name + ".launch");

View File

@ -84,6 +84,10 @@ public class GenIdeaProjectTask extends AbstractLoomTask {
}
for (RunConfigSettings settings : getExtension().getRunConfigs()) {
if (!settings.shouldGenerateIDEConfig()) {
continue;
}
runManager.appendChild(RunConfig.runConfig(project, settings).genRuns(runManager));
settings.makeRunDir();
}

View File

@ -64,6 +64,10 @@ public class GenVsCodeProjectTask extends AbstractLoomTask {
VsCodeLaunch launch = new VsCodeLaunch();
for (RunConfigSettings settings : getExtension().getRunConfigs()) {
if (!settings.shouldGenerateIDEConfig()) {
continue;
}
launch.add(RunConfig.runConfig(project, settings));
settings.makeRunDir();
}