|
4 | 4 | import java.io.IOException; |
5 | 5 | import java.nio.file.Files; |
6 | 6 | import java.util.ArrayList; |
| 7 | +import java.util.HashMap; |
7 | 8 | import java.util.List; |
8 | 9 | import java.util.Map; |
9 | 10 | import java.util.Set; |
@@ -175,7 +176,7 @@ private static void addIntelliJRunConfiguration(Project project, |
175 | 176 | @Nullable Function<Project, File> outputDirectory, |
176 | 177 | RunModel run, |
177 | 178 | PrepareRun prepareTask) { |
178 | | - var appRun = new Application(run.getIdeName().get(), project); |
| 179 | + var appRun = new ExtendedApplication(run.getIdeName().get(), project, getExtraIntelijRunProperties(run)); |
179 | 180 | var sourceSets = ExtensionUtils.getSourceSets(project); |
180 | 181 | var sourceSet = run.getSourceSet().get(); |
181 | 182 | // Validate that the source set is part of this project |
@@ -269,4 +270,29 @@ private static String getIntellijModuleName(Project project, SourceSet sourceSet |
269 | 270 | moduleName.append(sourceSet.getName()); |
270 | 271 | return moduleName.toString(); |
271 | 272 | } |
| 273 | + |
| 274 | + private static Map<String, Object> getExtraIntelijRunProperties(RunModel run) { |
| 275 | + var extraProperties = new HashMap<String, Object>(); |
| 276 | + if (!run.getIdeFolderName().get().isEmpty()) { |
| 277 | + extraProperties.put("folderName", run.getIdeFolderName().get()); |
| 278 | + } |
| 279 | + return extraProperties; |
| 280 | + } |
| 281 | + |
| 282 | + private static class ExtendedApplication extends Application { |
| 283 | + private final Map<String, Object> extraProperties; |
| 284 | + |
| 285 | + public ExtendedApplication(String name, Project project, Map<String, Object> extraProperties) { |
| 286 | + super(name, project); |
| 287 | + this.extraProperties = extraProperties; |
| 288 | + } |
| 289 | + |
| 290 | + @Override |
| 291 | + public Map<String, ?> toMap() { |
| 292 | + @SuppressWarnings("unchecked") |
| 293 | + var m = (Map<String, Object>) super.toMap(); |
| 294 | + m.putAll(extraProperties); |
| 295 | + return m; |
| 296 | + } |
| 297 | + } |
272 | 298 | } |
0 commit comments