Skip to content

Commit

Permalink
Maven CLI: bettter verbose + added debug for upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Oct 18, 2023
1 parent 996730b commit baa26ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public Integer updateProject(TargetQuarkusVersionGroup targetQuarkusVersion, Rew
args.add(ToolsUtils.getPluginKey(props) + ":" + ToolsUtils.getMavenPluginVersion(props) + ":update");
args.add("-e");
args.add("-N");
if (output.isVerbose()) {
args.add("-X");
}
if (targetQuarkusVersion.platformVersion != null) {
args.add("-DplatformVersion=" + targetQuarkusVersion.platformVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static FetchResult fetchRecipes(MessageWriter log, MavenArtifactResolver
final Artifact artifact = artifactResolver.resolve(DependencyUtils.toArtifact(gav)).getArtifact();
final ResourceLoader resourceLoader = ResourceLoaders.resolveFileResourceLoader(
artifact.getFile());
final List<String> recipes = fetchRecipesAsList(resourceLoader, "quarkus-updates", recipeDirectoryNames);
final List<String[]> recipes = fetchRecipesAsList(resourceLoader, "quarkus-updates", recipeDirectoryNames);
final Properties props = resourceLoader.loadResourceAsPath("quarkus-updates/", p -> {
final Properties properties = new Properties();
final Path propPath = p.resolve("recipes.properties");
Expand All @@ -77,8 +77,16 @@ public static FetchResult fetchRecipes(MessageWriter log, MavenArtifactResolver
targetVersion,
buildTool,
propRewritePluginVersion));
log.debug(String.format(
"Detected dependencies:\n %s ",
recipeDirectoryNames.entrySet().stream()
.map(e -> String.format("%s (%s -> %s)", e.getKey(), e.getValue()[0], e.getValue()[1]))
.sorted().collect(Collectors.joining("\n"))));
log.debug(String.format(
"Detected recipe(s):\n %s",
recipes.stream().map(o -> o[0]).sorted().collect(Collectors.joining("\n"))));
return new FetchResult(artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(),
recipes, propRewritePluginVersion);
recipes.stream().map(o -> o[1]).collect(Collectors.toList()), propRewritePluginVersion);
} catch (BootstrapMavenException e) {
throw new RuntimeException("Failed to resolve artifact: " + gav, e);
} catch (IOException e) {
Expand Down Expand Up @@ -133,7 +141,7 @@ static boolean shouldApplyRecipe(String recipeFileName, String currentVersion, S
return currentAVersion.compareTo(recipeAVersion) < 0 && targetAVersion.compareTo(recipeAVersion) >= 0;
}

static List<String> fetchRecipesAsList(ResourceLoader resourceLoader, String location,
static List<String[]> fetchRecipesAsList(ResourceLoader resourceLoader, String location,
Map<String, String[]> recipeDirectoryNames) throws IOException {
return resourceLoader.loadResourceAsPath(location,
path -> {
Expand All @@ -152,7 +160,8 @@ static List<String> fetchRecipesAsList(ResourceLoader resourceLoader, String loc
versions[0], versions[1]))
.map(p -> {
try {
return new String(Files.readAllBytes(p));
return new String[] { p.toString(),
new String(Files.readAllBytes(p)) };
} catch (IOException e) {
throw new RuntimeException("Error reading file: " + p, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void testShouldLoadRecipesFromTheDirectory() throws IOException {
recipeDirectoryNames.put("core", new String[] { "2.7", "3.1" });
recipeDirectoryNames.put("org.apache.camel.quarkus:camel-quarkus-core", new String[] { "2.7", "3.0" });
ClassPathResourceLoader resourceLoader = new ClassPathResourceLoader();
List<String> recipes = fetchRecipesAsList(resourceLoader, "dir/quarkus-update", recipeDirectoryNames);
List<String[]> recipes = fetchRecipesAsList(resourceLoader, "dir/quarkus-update", recipeDirectoryNames);
int noOfRecipes = recipes.size();
assertEquals(3, noOfRecipes);

Expand Down

0 comments on commit baa26ce

Please sign in to comment.