Skip to content

Commit

Permalink
Consistent ordering of migrated properties
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Nov 23, 2023
1 parent 45c7637 commit 4b09166
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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" +
Expand Down

0 comments on commit 4b09166

Please sign in to comment.