Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/main/java/net/neoforged/moddevgradle/dsl/RunModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public RunModel(String name, Project project, Iterable<ModModel> defaultMods) {
ideName = project.getName() + " - " + ideName;
}
getIdeName().convention(ideName);
getIdeFolderName().convention("");

getSourceSet().convention(ExtensionUtils.getSourceSets(project).getByName(SourceSet.MAIN_SOURCE_SET_NAME));
}
Expand All @@ -80,6 +81,12 @@ public String getName() {
*/
public abstract Property<String> getIdeName();

/**
* Name for the folder the run configuration is contained by in the IDE.
* If this is set to {@code ""}, no folder will be used.
*/
public abstract Property<String> getIdeFolderName();

/**
* Directory that the game will run in. Defaults to {@code run/}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -175,7 +176,7 @@ private static void addIntelliJRunConfiguration(Project project,
@Nullable Function<Project, File> outputDirectory,
RunModel run,
PrepareRun prepareTask) {
var appRun = new Application(run.getIdeName().get(), project);
var appRun = new ExtendedApplication(run.getIdeName().get(), project, getExtraIntelijRunProperties(run));
var sourceSets = ExtensionUtils.getSourceSets(project);
var sourceSet = run.getSourceSet().get();
// Validate that the source set is part of this project
Expand Down Expand Up @@ -269,4 +270,29 @@ private static String getIntellijModuleName(Project project, SourceSet sourceSet
moduleName.append(sourceSet.getName());
return moduleName.toString();
}

private static Map<String, Object> getExtraIntelijRunProperties(RunModel run) {
var extraProperties = new HashMap<String, Object>();
if (!run.getIdeFolderName().get().isEmpty()) {
extraProperties.put("folderName", run.getIdeFolderName().get());
}
return extraProperties;
}

private static class ExtendedApplication extends Application {
private final Map<String, Object> extraProperties;

public ExtendedApplication(String name, Project project, Map<String, Object> extraProperties) {
super(name, project);
this.extraProperties = extraProperties;
}

@Override
public Map<String, ?> toMap() {
@SuppressWarnings("unchecked")
var m = (Map<String, Object>) super.toMap();
m.putAll(extraProperties);
return m;
}
}
}
4 changes: 4 additions & 0 deletions testproject/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ neoForge {
client()
programArguments.addAll('--username', 'Dev2')
}
folderedClient {
client()
ideFolderName = "Neo Test Folder"
}
clientAuth {
client()
devLogin = true
Expand Down
Loading