Skip to content

Commit 1887469

Browse files
committed
Do not clean for process-sources or we lost the target/rewrite dir
Also improve a bit the formatting of the log file.
1 parent 4b4fcad commit 1887469

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdateCommand.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.io.BufferedReader;
66
import java.io.File;
7+
import java.io.IOException;
78
import java.io.InputStream;
89
import java.io.InputStreamReader;
910
import java.nio.charset.StandardCharsets;
@@ -155,7 +156,6 @@ private static List<String> getMavenProcessSourcesCommand(String mvnBinary) {
155156
command.add(mvnBinary);
156157
command.add("-B");
157158
command.add("-e");
158-
command.add("clean");
159159
command.add("process-sources");
160160
final String mavenSettings = getMavenSettingsArg();
161161
if (mavenSettings != null) {
@@ -195,10 +195,23 @@ private static void executeRewrite(Path baseDir, Map<String, List<String>> comma
195195

196196
log.info("");
197197

198-
String logInfo = logFile != null ? "Logs can be found at: %s".formatted(baseDir.relativize(logFile).toString())
199-
: "See the execution logs above for more details";
198+
String logInfo;
199+
200+
if (logFile != null) {
201+
logInfo = "Logs can be found at: %s".formatted(baseDir.relativize(logFile).toString());
202+
203+
try {
204+
// we delete the log file prior to executing the command so that we start clean
205+
Files.deleteIfExists(logFile);
206+
} catch (IOException e) {
207+
// ignore, it's not a big deal
208+
}
209+
} else {
210+
logInfo = "See the execution logs above for more details";
211+
}
200212

201213
log.info("Update in progress (this may take a while):");
214+
202215
for (Map.Entry<String, List<String>> e : commands.entrySet()) {
203216
log.info(" - executing " + e.getKey() + " command...");
204217
execute(e.getKey(), e.getValue(), log, logFile, logInfo);
@@ -218,7 +231,7 @@ private static void execute(String name, List<String> command, MessageWriter log
218231

219232
try {
220233
if (logFile != null) {
221-
Files.writeString(logFile, "\n\n\nRunning: " + String.join(" ", effectiveCommand) + "\n",
234+
Files.writeString(logFile, "Running: " + String.join(" ", effectiveCommand) + "\n",
222235
StandardOpenOption.APPEND, StandardOpenOption.CREATE);
223236
}
224237

@@ -260,14 +273,17 @@ private static void execute(String name, List<String> command, MessageWriter log
260273
}
261274

262275
log.info("");
263-
264276
}
265277

266278
int exitCode = process.waitFor();
267279
if (exitCode != 0) {
268280
log.info("");
269281
throw new QuarkusUpdateExitErrorException("The %s command exited with an error. %s".formatted(name, logInfo));
270282
}
283+
284+
if (logFile != null) {
285+
Files.writeString(logFile, "\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
286+
}
271287
} catch (QuarkusUpdateException e) {
272288
throw e;
273289
} catch (Exception e) {

0 commit comments

Comments
 (0)