rewrite-spring icon indicating copy to clipboard operation
rewrite-spring copied to clipboard

Recipe to migrate properties configuration to yaml configuration (and vice versa)

Open murdos opened this issue 1 year ago • 2 comments

What problem are you trying to solve?

Migration of an existing application that uses properties for Spring configuration to use of YAML for Spring configuration.

What precondition(s) should be checked before applying this recipe?

Existence of application*.properties files.

Describe the situation before applying the recipe

src/main/resources/config/application.properties

server.port=${PORT:8080}
logging.level.org.atmosphere = warn
spring.mustache.check-template-location = false

Describe the situation after applying the recipe

src/main/resources/config/application.yml

server:
  port: ${PORT:8080}
logging:
  level:
    org.atmosphere: warn
spring:
  mustache:
    check-template-location: false

Have you considered any alternatives or workarounds?

Any additional context

Are you interested in contributing this recipe to OpenRewrite?

murdos avatar Mar 16 '24 21:03 murdos

@timtebeek I have the start of a recipe properties->yaml and some infrastructure to support conversion either way.

I am reluctant to contribute it back (especially in this library).

https://github.com/tkvangorder/rewrite-sandbox/blob/main/src/main/java/org/openrewrite/contrib/convert/ConvertPropertiesToYaml.java

If you want to take the time to copy the code over, go for it.

tkvangorder avatar Feb 24 '25 16:02 tkvangorder

Much appreciated, thanks! I'm out for the next two weeks, but could be interesting to take on after. Or anyone else that wants to step up in the mean time.

timtebeek avatar Feb 24 '25 22:02 timtebeek