|
12 | 12 | import net.neoforged.gradle.common.util.ProjectUtils; |
13 | 13 | import net.neoforged.gradle.common.util.SourceSetUtils; |
14 | 14 | import net.neoforged.gradle.common.util.run.RunsUtil; |
| 15 | +import net.neoforged.gradle.dsl.common.extensions.Minecraft; |
15 | 16 | import net.neoforged.gradle.dsl.common.extensions.subsystems.Subsystems; |
16 | 17 | import net.neoforged.gradle.dsl.common.extensions.subsystems.conventions.ide.IDEA; |
17 | 18 | import net.neoforged.gradle.dsl.common.runs.ide.extensions.IdeaRunExtension; |
@@ -83,8 +84,25 @@ public void setup(final Project project) { |
83 | 84 | final IdeaModel ideaModel = rootProject.getExtensions().getByType(IdeaModel.class); |
84 | 85 | final IdeaProject ideaProject = ideaModel.getProject(); |
85 | 86 | final ExtensionAware extensionAware = (ExtensionAware) ideaProject; |
| 87 | + final IdeaRunsExtension global; |
86 | 88 | if (extensionAware.getExtensions().findByType(IdeaRunsExtension.class) == null && extensionAware.getExtensions().findByName("runs") == null) { |
87 | | - extensionAware.getExtensions().create("runs", IdeaRunsExtension.class, project); |
| 89 | + global = extensionAware.getExtensions().create("runs", IdeaRunsExtension.class, project); |
| 90 | + } |
| 91 | + else if (extensionAware.getExtensions().findByType(IdeaRunsExtension.class) != null) |
| 92 | + { |
| 93 | + global = extensionAware.getExtensions().findByType(IdeaRunsExtension.class); |
| 94 | + } |
| 95 | + else |
| 96 | + { |
| 97 | + project.getLogger().warn("Runs extension for idea can not be registered on the Idea project model. Use the one in the minecraft extension."); |
| 98 | + global = null; |
| 99 | + } |
| 100 | + |
| 101 | + final Minecraft minecraft = project.getExtensions().getByType(Minecraft.class); |
| 102 | + final IdeaRunsExtension projectLocal = minecraft.getExtensions().create("idea", IdeaRunsExtension.class, project); |
| 103 | + if (global != null) { |
| 104 | + projectLocal.getUseArgsFile().convention(global.getUseArgsFile()); |
| 105 | + projectLocal.getRunWithIdea().convention(global.getRunWithIdea()); |
88 | 106 | } |
89 | 107 | } |
90 | 108 |
|
@@ -123,6 +141,8 @@ public void configureIdeaConventions(Project project, IDEA ideaConventions) { |
123 | 141 | return FileUtils.contains(GradleXml, "<option name=\"delegatedBuild\" value=\"false\" />"); |
124 | 142 | }) |
125 | 143 | ); |
| 144 | + |
| 145 | + runsExtension.getUseArgsFile().convention(ideaConventions.getShouldUseArgsFile()); |
126 | 146 | } |
127 | 147 |
|
128 | 148 | private static final class RunsImportAction implements IdeManagementExtension.IdeImportAction { |
@@ -175,6 +195,9 @@ private void createIdeaRun(Project project, Run run, RunConfigurationContainer i |
175 | 195 | if (!defaultRun && !run.getShouldExportToIDE().get()) |
176 | 196 | return; |
177 | 197 |
|
| 198 | + final Minecraft minecraft = project.getExtensions().getByType(Minecraft.class); |
| 199 | + final IdeaRunsExtension ideaRunsExtension = minecraft.getExtensions().getByType(IdeaRunsExtension.class); |
| 200 | + |
178 | 201 | final String ideRunName = run.getIDERunName().isPresent() ? run.getIDERunName().get() : run.getName(); |
179 | 202 | final String runName = StringUtils.capitalize(project.getName() + ": " + StringUtils.capitalize(ideRunName)); |
180 | 203 |
|
@@ -208,7 +231,9 @@ private void createIdeaRun(Project project, Run run, RunConfigurationContainer i |
208 | 231 | ideaRun.setModuleName(RunsUtil.getIntellijModuleName(run.getExtensions().getByType(IdeaRunExtension.class).getPrimarySourceSet().get())); |
209 | 232 | ideaRun.setProgramParameters(RunsUtil.escapeAndJoin(RunsUtil.deduplicateElementsFollowingEachOther(programArguments.stream()).collect(Collectors.toList()))); |
210 | 233 | ideaRun.setEnvs(productionEnvironment); |
211 | | - ideaRun.setShortenCommandLine(ShortenCommandLine.ARGS_FILE); |
| 234 | + |
| 235 | + if (ideaRunsExtension.getUseArgsFile().get()) |
| 236 | + ideaRun.setShortenCommandLine(ShortenCommandLine.ARGS_FILE); |
212 | 237 |
|
213 | 238 | ideaRun.beforeRun(beforeRuns -> { |
214 | 239 | beforeRuns.create("Build", Make.class); |
@@ -240,7 +265,9 @@ private void createIdeaRun(Project project, Run run, RunConfigurationContainer i |
240 | 265 | "@%s".formatted(preparedUnitTestEnvironment.jvmArgumentsFile().getAbsolutePath()) |
241 | 266 | )); |
242 | 267 | ideaRun.setEnvs(testEnvironment); |
243 | | - ideaRun.setShortenCommandLine(ShortenCommandLine.ARGS_FILE); |
| 268 | + |
| 269 | + if (ideaRunsExtension.getUseArgsFile().get()) |
| 270 | + ideaRun.setShortenCommandLine(ShortenCommandLine.ARGS_FILE); |
244 | 271 |
|
245 | 272 | ideaRun.beforeRun(beforeRuns -> { |
246 | 273 | beforeRuns.create("Build", Make.class); |
|
0 commit comments