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
parent
6b481fbcd6
commit
24c166fc79
|
@ -60,7 +60,6 @@ public class LoomGradleExtension {
|
||||||
public String refmapName;
|
public String refmapName;
|
||||||
public String loaderLaunchMethod;
|
public String loaderLaunchMethod;
|
||||||
public boolean remapMod = true;
|
public boolean remapMod = true;
|
||||||
public boolean autoGenIDERuns;
|
|
||||||
public String customManifest = null;
|
public String customManifest = null;
|
||||||
public File accessWidener = null;
|
public File accessWidener = null;
|
||||||
public Function<String, Object> intermediaryUrl = mcVer -> "https://maven.fabricmc.net/net/fabricmc/intermediary/" + mcVer + "/intermediary-" + mcVer + "-v2.jar";
|
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) {
|
public LoomGradleExtension(Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.autoGenIDERuns = isRootProject();
|
|
||||||
this.unmappedMods = project.files();
|
this.unmappedMods = project.files();
|
||||||
this.runConfigs = project.container(RunConfigSettings.class,
|
this.runConfigs = project.container(RunConfigSettings.class,
|
||||||
baseName -> new RunConfigSettings(project, baseName));
|
baseName -> new RunConfigSettings(project, baseName));
|
||||||
|
|
|
@ -168,9 +168,7 @@ public final class CompileConfiguration {
|
||||||
project1.getTasks().getByName("eclipse").finalizedBy(project1.getTasks().getByName("genEclipseRuns"));
|
project1.getTasks().getByName("eclipse").finalizedBy(project1.getTasks().getByName("genEclipseRuns"));
|
||||||
project1.getTasks().getByName("cleanEclipse").finalizedBy(project1.getTasks().getByName("cleanEclipseRuns"));
|
project1.getTasks().getByName("cleanEclipse").finalizedBy(project1.getTasks().getByName("cleanEclipseRuns"));
|
||||||
|
|
||||||
if (extension.autoGenIDERuns) {
|
SetupIntelijRunConfigs.setup(project1);
|
||||||
SetupIntelijRunConfigs.setup(project1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enables the default mod remapper
|
// Enables the default mod remapper
|
||||||
if (extension.remapMod) {
|
if (extension.remapMod) {
|
||||||
|
|
|
@ -92,6 +92,13 @@ public final class RunConfigSettings implements Named {
|
||||||
*/
|
*/
|
||||||
private final String baseName;
|
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 Project project;
|
||||||
private final LoomGradleExtension extension;
|
private final LoomGradleExtension extension;
|
||||||
|
|
||||||
|
@ -99,6 +106,7 @@ public final class RunConfigSettings implements Named {
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
|
this.generateIDEConfig = extension.isRootProject();
|
||||||
|
|
||||||
source("main");
|
source("main");
|
||||||
runDir("run");
|
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.
|
* Add the {@code -XstartOnFirstThread} JVM argument when on OSX.
|
||||||
*/
|
*/
|
||||||
|
@ -287,4 +299,8 @@ public final class RunConfigSettings implements Named {
|
||||||
file.mkdir();
|
file.mkdir();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldGenerateIDEConfig() {
|
||||||
|
return generateIDEConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,10 @@ public class SetupIntelijRunConfigs {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RunConfigSettings settings : extension.getRunConfigs()) {
|
for (RunConfigSettings settings : extension.getRunConfigs()) {
|
||||||
|
if (!settings.shouldGenerateIDEConfig()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
RunConfig config = RunConfig.runConfig(project, settings);
|
RunConfig config = RunConfig.runConfig(project, settings);
|
||||||
String name = config.configName.replaceAll("[^a-zA-Z0-9$_]", "_");
|
String name = config.configName.replaceAll("[^a-zA-Z0-9$_]", "_");
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,10 @@ public class GenEclipseRunsTask extends AbstractLoomTask {
|
||||||
LoomGradleExtension extension = getExtension();
|
LoomGradleExtension extension = getExtension();
|
||||||
|
|
||||||
for (RunConfigSettings settings : extension.getRunConfigs()) {
|
for (RunConfigSettings settings : extension.getRunConfigs()) {
|
||||||
|
if (!settings.shouldGenerateIDEConfig()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String name = settings.getName();
|
String name = settings.getName();
|
||||||
|
|
||||||
File configs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_" + name + ".launch");
|
File configs = new File(getProject().getRootDir(), eclipseModel.getProject().getName() + "_" + name + ".launch");
|
||||||
|
|
|
@ -84,6 +84,10 @@ public class GenIdeaProjectTask extends AbstractLoomTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RunConfigSettings settings : getExtension().getRunConfigs()) {
|
for (RunConfigSettings settings : getExtension().getRunConfigs()) {
|
||||||
|
if (!settings.shouldGenerateIDEConfig()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
runManager.appendChild(RunConfig.runConfig(project, settings).genRuns(runManager));
|
runManager.appendChild(RunConfig.runConfig(project, settings).genRuns(runManager));
|
||||||
settings.makeRunDir();
|
settings.makeRunDir();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,10 @@ public class GenVsCodeProjectTask extends AbstractLoomTask {
|
||||||
VsCodeLaunch launch = new VsCodeLaunch();
|
VsCodeLaunch launch = new VsCodeLaunch();
|
||||||
|
|
||||||
for (RunConfigSettings settings : getExtension().getRunConfigs()) {
|
for (RunConfigSettings settings : getExtension().getRunConfigs()) {
|
||||||
|
if (!settings.shouldGenerateIDEConfig()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
launch.add(RunConfig.runConfig(project, settings));
|
launch.add(RunConfig.runConfig(project, settings));
|
||||||
settings.makeRunDir();
|
settings.makeRunDir();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue