Skip to content

Commit 35eff71

Browse files
authored
Fix TaskPreprocessVersion silently failing (#31)
2 parents 1348b4b + 7ae29b8 commit 35eff71

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main/java/com/minecrafttas/discombobulator/tasks/TaskPreprocessVersion.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.minecrafttas.discombobulator.tasks;
22

3+
import static com.minecrafttas.discombobulator.utils.Colors.CYAN;
4+
import static com.minecrafttas.discombobulator.utils.Colors.WHITE;
5+
36
import java.nio.charset.MalformedInputException;
47
import java.nio.file.Files;
58
import java.nio.file.Path;
@@ -62,9 +65,11 @@ public void preprocessVersion() throws Exception {
6265
throw new Exception("Version could not be found in build.gradle");
6366
}
6467

68+
String masterVersionName = masterVersion.left();
69+
6570
LineFeedHelper.printMessage();
6671

67-
System.out.println(String.format("Preprocessing version %s...", masterVersion.left()));
72+
System.out.println(String.format("Preprocessing version %s...", masterVersionName));
6873

6974
Path versionSourceDir = versionProjectDir.resolve("src");
7075
if (!Files.exists(versionSourceDir))
@@ -77,11 +82,17 @@ public void preprocessVersion() throws Exception {
7782
try {
7883
// Preprocess version dir
7984
CurrentFilePreprocessAction action = Discombobulator.fileProcessor.preprocessVersions(inFile, versionsConfig, extension, versionSourceDir, true);
80-
TaskPreprocessWatch.runFileAction(action);
8185

8286
// Preprocess in base dir
8387
Path outFile = baseSourceDir.resolve(path);
8488
Discombobulator.fileProcessor.preprocessFile(inFile, outFile, null, extension);
89+
90+
/* Action has to run after the base dir preprocessing,
91+
* as runFileAction locks the file, and base dir preprocessing silently would fail*/
92+
if (action != null) {
93+
System.out.println(String.format("into version %s%s%s", CYAN, masterVersionName, WHITE));
94+
TaskPreprocessWatch.runFileAction(action);
95+
}
8596
} catch (MalformedInputException e) {
8697
Discombobulator.printError(String.format("Can't process file, probably not a text file...\n Maybe add ignoredFileFormats = [\"*.%s\"] to the build.gradle?", extension), path.getFileName().toString());
8798
e.printStackTrace();

0 commit comments

Comments
 (0)