Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort output of discover mojo (#630) #632

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/main/java/org/openrewrite/maven/RewriteDiscoverMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
import org.openrewrite.maven.ui.RecipeDescriptorTreePrompter;
import org.openrewrite.style.NamedStyles;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;

/**
* Generate a report of the available recipes and styles found on the classpath.<br>
Expand Down Expand Up @@ -95,26 +99,34 @@ public void execute() throws MojoExecutionException {
}

private void writeDiscovery(Collection<RecipeDescriptor> availableRecipeDescriptors, Collection<RecipeDescriptor> activeRecipeDescriptors, Collection<NamedStyles> availableStyles) {
List<RecipeDescriptor> availableRecipesSorted = new ArrayList<>(availableRecipeDescriptors);
availableRecipesSorted.sort(Comparator.comparing(RecipeDescriptor::getName, String.CASE_INSENSITIVE_ORDER));
getLog().info("Available Recipes:");
for (RecipeDescriptor recipeDescriptor : availableRecipeDescriptors) {
for (RecipeDescriptor recipeDescriptor : availableRecipesSorted) {
writeRecipeDescriptor(recipeDescriptor, detail, 0, 1);
}

List<NamedStyles> availableStylesSorted = new ArrayList<>(availableStyles);
availableStylesSorted.sort(Comparator.comparing(NamedStyles::getName, String.CASE_INSENSITIVE_ORDER));
getLog().info("");
getLog().info("Available Styles:");
for (NamedStyles style : availableStyles) {
for (NamedStyles style : availableStylesSorted) {
getLog().info(" " + style.getName());
}

List<String> activeStylesSorted = new ArrayList<>(getActiveStyles());
activeStylesSorted.sort(String.CASE_INSENSITIVE_ORDER);
getLog().info("");
getLog().info("Active Styles:");
for (String activeStyle : getActiveStyles()) {
for (String activeStyle : activeStylesSorted) {
getLog().info(" " + activeStyle);
}

List<RecipeDescriptor> activeRecipesSorted = new ArrayList<>(activeRecipeDescriptors);
activeRecipesSorted.sort(Comparator.comparing(RecipeDescriptor::getName, String.CASE_INSENSITIVE_ORDER));
getLog().info("");
getLog().info("Active Recipes:");
for (RecipeDescriptor recipeDescriptor : activeRecipeDescriptors) {
for (RecipeDescriptor recipeDescriptor : activeRecipesSorted) {
writeRecipeDescriptor(recipeDescriptor, detail, 0, 1);
}

Expand Down