Use rewrite release versions. Workaround for xml-bind.

This commit is contained in:
aboyko
2023-06-14 13:23:48 -04:00
parent 3af4beac80
commit 8c9692fa18
5 changed files with 18 additions and 8 deletions

View File

@@ -55,9 +55,7 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
"org.openrewrite.java.spring.boot2.SpringBoot1To2Migration",
"org.openrewrite.java.testing.junit5.JUnit5BestPractices",
"org.openrewrite.java.testing.junit5.JUnit4to5Migration",
"org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_6",
"org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7",
"org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0",
"org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1",
"org.rewrite.java.security.*",
"org.springframework.rewrite.test.*",

View File

@@ -52,7 +52,7 @@ public class LoadUtils {
}
public static Recipe createRecipe(RecipeDescriptor d, Function<String, Class<? extends Recipe>> getRecipeClass) {
Class<? extends Recipe> recipeClazz = getRecipeClass.apply(d.getName());
Class<? extends Recipe> recipeClazz = getRecipeClass == null ? null : getRecipeClass.apply(d.getName());
if (recipeClazz == null || DeclarativeRecipe.class.getName().equals(recipeClazz.getName())) {
DeclarativeRecipe recipe = new DeclarativeRecipe(d.getName(), d.getDisplayName(), d.getDescription(),
d.getTags(), d.getEstimatedEffortPerOccurrence(), d.getSource(), false, d.getMaintainers());

View File

@@ -113,9 +113,9 @@
<commons-codec-version>1.13</commons-codec-version>
<!-- Rewrite specific properties -->
<rewrite-version>8.1.1</rewrite-version>
<rewrite-spring-version>5.1.0-SNAPSHOT</rewrite-spring-version>
<rewrite-gradle-tooling-api-version>1.1.0-SNAPSHOT</rewrite-gradle-tooling-api-version>
<rewrite-version>8.1.2</rewrite-version>
<rewrite-spring-version>5.0.1</rewrite-spring-version>
<rewrite-gradle-tooling-api-version>1.0.0</rewrite-gradle-tooling-api-version>
<gradle-tooling.version>7.6</gradle-tooling.version>
<gradle-core.version>6.1.1</gradle-core.version>

View File

@@ -188,15 +188,29 @@ public class RewriteRecipeRepository implements ApplicationContextAware {
IndefiniteProgressTask progressTask = server.getProgressService().createIndefiniteProgressTask(UUID.randomUUID().toString(), "Loading Rewrite Recipes", null);
try {
log.info("Loading Rewrite Recipes...");
Recipe xmlbindRecipe = null;
StsEnvironment env = createRewriteEnvironment();
for (Recipe r : env.listRecipes()) {
if (r.getName() != null) {
if ("org.openrewrite.java.migrate.jakarta.JavaxXmlBindMigrationToJakartaXmlBind".equals(r.getName())) {
xmlbindRecipe = r;
}
if (recipes.containsKey(r.getName())) {
log.error("Duplicate ids: '" + r.getName() + "'");
}
recipes.put(r.getName(), r);
}
}
// HACK: add Jakarta XML Bind migration recipe again as there are cases when maven dependency isn't added
if (xmlbindRecipe != null) {
for (String id : recipes.keySet()) {
if (id.startsWith("org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_")) {
Recipe recipe = recipes.get(id);
recipe.getDescriptor().getRecipeList().add(xmlbindRecipe.getDescriptor());
recipe.getRecipeList().add(xmlbindRecipe);
}
}
}
codeActionDescriptors.addAll(env.listCodeActionDescriptors());
log.info("Done loading Rewrite Recipes");
} catch (Throwable t) {

View File

@@ -246,9 +246,7 @@
"org.openrewrite.java.spring.boot2.SpringBoot1To2Migration",
"org.openrewrite.java.testing.junit5.JUnit5BestPractices",
"org.openrewrite.java.testing.junit5.JUnit4to5Migration",
"org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_6",
"org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7",
"org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0",
"org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1",
"org.rewrite.java.security.*",
"org.springframework.rewrite.test.*",