Skip to content

Commit e9912b5

Browse files
authored
Merge pull request #37428 from gsmet/quarkus-update-enhancements
Fix various minor issues in quarkus update
2 parents 221b681 + 553c361 commit e9912b5

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

independent-projects/tools/devtools-common/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<groupId>io.smallrye.common</groupId>
5151
<artifactId>smallrye-common-version</artifactId>
5252
</dependency>
53+
<dependency>
54+
<groupId>io.smallrye.common</groupId>
55+
<artifactId>smallrye-common-os</artifactId>
56+
</dependency>
5357
<dependency>
5458
<groupId>io.fabric8</groupId>
5559
<artifactId>maven-model-helper</artifactId>

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

+18-24
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import io.quarkus.devtools.messagewriter.MessageWriter;
2525
import io.quarkus.devtools.project.BuildTool;
2626
import io.quarkus.qute.Qute;
27+
import io.smallrye.common.os.OS;
2728

2829
public class QuarkusUpdateCommand {
2930

@@ -57,6 +58,16 @@ public static void handle(MessageWriter log, BuildTool buildTool, Path baseDir,
5758
}
5859
}
5960

61+
private static void runMavenUpdate(MessageWriter log, Path baseDir, String rewritePluginVersion, String recipesGAV,
62+
Path recipe,
63+
boolean dryRun) {
64+
final String mvnBinary = findMvnBinary(baseDir);
65+
executeCommand(baseDir, getMavenUpdateCommand(mvnBinary, rewritePluginVersion, recipesGAV, recipe, dryRun), log);
66+
67+
// format the sources
68+
executeCommand(baseDir, getMavenProcessSourcesCommand(mvnBinary), log);
69+
}
70+
6071
private static void runGradleUpdate(MessageWriter log, Path baseDir, String rewritePluginVersion, String recipesGAV,
6172
Path recipe, boolean dryRun) {
6273
Path tempInit = null;
@@ -119,19 +130,11 @@ private static void propagateSystemPropertyIfSet(String name, List<String> comma
119130
}
120131
}
121132

122-
private static void runMavenUpdate(MessageWriter log, Path baseDir, String rewritePluginVersion, String recipesGAV,
123-
Path recipe,
124-
boolean dryRun) {
125-
final String mvnBinary = findMvnBinary(baseDir);
126-
executeCommand(baseDir, getMavenUpdateCommand(mvnBinary, rewritePluginVersion, recipesGAV, recipe, dryRun), log);
127-
128-
// format the sources
129-
executeCommand(baseDir, getMavenProcessSourcesCommand(mvnBinary), log);
130-
}
131-
132133
private static List<String> getMavenProcessSourcesCommand(String mvnBinary) {
133134
List<String> command = new ArrayList<>();
134135
command.add(mvnBinary);
136+
command.add("-B");
137+
command.add("clean");
135138
command.add("process-sources");
136139
final String mavenSettings = getMavenSettingsArg();
137140
if (mavenSettings != null) {
@@ -146,6 +149,7 @@ private static List<String> getMavenUpdateCommand(String mvnBinary, String rewri
146149
boolean dryRun) {
147150
final List<String> command = new ArrayList<>();
148151
command.add(mvnBinary);
152+
command.add("-B");
149153
command.add("-e");
150154
command.add(
151155
String.format("%s:%s:%s:%s", MAVEN_REWRITE_PLUGIN_GROUP, MAVEN_REWRITE_PLUGIN_ARTIFACT, rewritePluginVersion,
@@ -305,18 +309,8 @@ private static boolean isExecutable(Path file) {
305309
return false;
306310
}
307311

308-
private static String OS = System.getProperty("os.name").toLowerCase();
309-
310312
public static boolean isWindows() {
311-
return OS.contains("win");
312-
}
313-
314-
static boolean hasGradle(Path dir) {
315-
return Files.exists(dir.resolve("build.gradle"));
316-
}
317-
318-
private static boolean hasMaven(Path dir) {
319-
return Files.exists(dir.resolve("pom.xml"));
313+
return OS.WINDOWS.isCurrent();
320314
}
321315

322316
private enum LogLevel {
@@ -351,13 +345,13 @@ private String clean(String line) {
351345
return line;
352346
}
353347

354-
String pattern = "[" + name() + "]";
348+
String pattern = "[" + name() + "] ";
355349

356-
if (line.length() < pattern.length()) {
350+
if (!line.startsWith(pattern)) {
357351
return line;
358352
}
359353

360-
return line.substring(pattern.length()).trim();
354+
return line.substring(pattern.length());
361355
}
362356

363357
private boolean matches(String line) {

0 commit comments

Comments
 (0)