4
4
5
5
import java .io .BufferedReader ;
6
6
import java .io .File ;
7
+ import java .io .IOException ;
7
8
import java .io .InputStream ;
8
9
import java .io .InputStreamReader ;
9
10
import java .nio .charset .StandardCharsets ;
@@ -155,7 +156,6 @@ private static List<String> getMavenProcessSourcesCommand(String mvnBinary) {
155
156
command .add (mvnBinary );
156
157
command .add ("-B" );
157
158
command .add ("-e" );
158
- command .add ("clean" );
159
159
command .add ("process-sources" );
160
160
final String mavenSettings = getMavenSettingsArg ();
161
161
if (mavenSettings != null ) {
@@ -195,10 +195,23 @@ private static void executeRewrite(Path baseDir, Map<String, List<String>> comma
195
195
196
196
log .info ("" );
197
197
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
+ }
200
212
201
213
log .info ("Update in progress (this may take a while):" );
214
+
202
215
for (Map .Entry <String , List <String >> e : commands .entrySet ()) {
203
216
log .info (" - executing " + e .getKey () + " command..." );
204
217
execute (e .getKey (), e .getValue (), log , logFile , logInfo );
@@ -218,7 +231,7 @@ private static void execute(String name, List<String> command, MessageWriter log
218
231
219
232
try {
220
233
if (logFile != null ) {
221
- Files .writeString (logFile , "\n \n \n Running : " + String .join (" " , effectiveCommand ) + "\n " ,
234
+ Files .writeString (logFile , "Running : " + String .join (" " , effectiveCommand ) + "\n " ,
222
235
StandardOpenOption .APPEND , StandardOpenOption .CREATE );
223
236
}
224
237
@@ -260,14 +273,17 @@ private static void execute(String name, List<String> command, MessageWriter log
260
273
}
261
274
262
275
log .info ("" );
263
-
264
276
}
265
277
266
278
int exitCode = process .waitFor ();
267
279
if (exitCode != 0 ) {
268
280
log .info ("" );
269
281
throw new QuarkusUpdateExitErrorException ("The %s command exited with an error. %s" .formatted (name , logInfo ));
270
282
}
283
+
284
+ if (logFile != null ) {
285
+ Files .writeString (logFile , "\n \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \n " );
286
+ }
271
287
} catch (QuarkusUpdateException e ) {
272
288
throw e ;
273
289
} catch (Exception e ) {
0 commit comments