From 4b091663ae8064b5d1fd248d86a491901fd3cd85 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 23 Nov 2023 17:46:10 +0100 Subject: [PATCH] Consistent ordering of migrated properties --- .../META-INF/rewrite/spring-boot-32-properties.yml | 12 ++++++------ .../GeneratePropertiesMigratorConfiguration.java | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/resources/META-INF/rewrite/spring-boot-32-properties.yml b/src/main/resources/META-INF/rewrite/spring-boot-32-properties.yml index ee3dcc6d2..8e312d8e3 100644 --- a/src/main/resources/META-INF/rewrite/spring-boot-32-properties.yml +++ b/src/main/resources/META-INF/rewrite/spring-boot-32-properties.yml @@ -22,6 +22,12 @@ tags: - spring - boot recipeList: + - org.openrewrite.java.spring.ChangeSpringPropertyKey: + oldPropertyKey: management.metrics.tags + newPropertyKey: management.observations.key-values + - org.openrewrite.java.spring.ChangeSpringPropertyKey: + oldPropertyKey: management.otlp.metrics.export.resource-attributes + newPropertyKey: management.opentelemetry.resource-attributes - org.openrewrite.java.spring.ChangeSpringPropertyKey: oldPropertyKey: server.max-http-header-size newPropertyKey: server.max-http-request-header-size @@ -46,10 +52,4 @@ recipeList: - org.openrewrite.java.spring.ChangeSpringPropertyKey: oldPropertyKey: spring.jms.listener.concurrency newPropertyKey: spring.jms.listener.min-concurrency - - org.openrewrite.java.spring.ChangeSpringPropertyKey: - oldPropertyKey: management.metrics.tags - newPropertyKey: management.observations.key-values - - org.openrewrite.java.spring.ChangeSpringPropertyKey: - oldPropertyKey: management.otlp.metrics.export.resource-attributes - newPropertyKey: management.opentelemetry.resource-attributes diff --git a/src/test/java/org/openrewrite/java/spring/internal/GeneratePropertiesMigratorConfiguration.java b/src/test/java/org/openrewrite/java/spring/internal/GeneratePropertiesMigratorConfiguration.java index f1c6e7056..e5d282088 100644 --- a/src/test/java/org/openrewrite/java/spring/internal/GeneratePropertiesMigratorConfiguration.java +++ b/src/test/java/org/openrewrite/java/spring/internal/GeneratePropertiesMigratorConfiguration.java @@ -28,10 +28,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import static java.util.Collections.emptySet; @@ -44,7 +41,7 @@ */ class GeneratePropertiesMigratorConfiguration { public static void main(String[] args) throws IOException { - var springBootReleases = new SpringBootReleases(true); + var springBootReleases = new SpringBootReleases(false); // `true` for release candidates var objectMapper = new ObjectMapper() .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); @@ -98,10 +95,15 @@ public static void main(String[] args) throws IOException { } }) .filter(p -> alreadyDefined.add(p.name())) + .sorted(Comparator.comparing(SpringConfigurationMetadata.ConfigurationProperty::name)) .toList(); if (!replacements.isEmpty()) { var majorMinor = version.split("\\."); + if ("2".equals(majorMinor[0]) || "3".equals(majorMinor[0]) && "0".equals(majorMinor[1])) { + // Don't override manual fixes to the unsupported 2.x and 3.0 versions + continue; + } var config = Paths.get("src/main/resources/META-INF/rewrite/spring-boot-%s%s-properties.yml".formatted(majorMinor[0], majorMinor[1])); Files.writeString(config, "#\n" +