Skip to content

Commit

Permalink
Fix spaces in Gradle user home breaking IntelliJ run configurations. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Nov 26, 2023
1 parent 7afa3cb commit 24a5f07
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -103,12 +104,9 @@ public void idea(Project project, IdeaModel idea, ProjectSettings ideaExtension)

ideaRun.setMainClass(runImpl.getMainClass().get());
ideaRun.setWorkingDirectory(runImpl.getWorkingDirectory().get().getAsFile().getAbsolutePath());
ideaRun.setJvmArgs(String.join(" ", runImpl.realiseJvmArguments()));
ideaRun.setJvmArgs(quoteAndJoin(runImpl.realiseJvmArguments()));
ideaRun.moduleRef(project, runIdeaConfig.getPrimarySourceSet().get());
ideaRun.setProgramParameters(runImpl.getProgramArguments().get()
.stream()
.map(arg -> "\"" + arg + "\"")
.collect(Collectors.joining(" ")));
ideaRun.setProgramParameters(quoteAndJoin(runImpl.getProgramArguments().get()));
ideaRun.setEnvs(adaptEnvironment(runImpl, RunsUtil::buildRunWithIdeaModClasses));
ideaRun.setShortenCommandLine(ShortenCommandLine.ARGS_FILE);

Expand All @@ -124,7 +122,11 @@ public void idea(Project project, IdeaModel idea, ProjectSettings ideaExtension)


}


private static String quoteAndJoin(List<String> args) {
return args.stream().map(arg -> "\"" + arg + "\"").collect(Collectors.joining(" "));
}

@Override
public void eclipse(Project project, EclipseModel eclipse) {
ProjectUtils.afterEvaluate(project, () -> {
Expand Down Expand Up @@ -176,7 +178,7 @@ public void eclipse(Project project, EclipseModel eclipse) {
}));
});
}

private TaskProvider<?> createIdeBeforeRunTask(Project project, String name, Run run, RunImpl runImpl) {
final TaskProvider<?> ideBeforeRunTask = project.getTasks().register(CommonRuntimeUtils.buildTaskName("ideBeforeRun", name), task -> {
for (SourceSet sourceSet : run.getModSources().get()) {
Expand Down

0 comments on commit 24a5f07

Please sign in to comment.