Common recipe customizations
While Moderne recipes handle a broad range of issues, most people find that they eventually need to create or customize recipes for their specific setup, configuration, or dependency. The best way to handle that is to create a custom declarative recipe that builds on the standard recipes – while incorporating your specific customization needs.
To help you get started with that, this doc will provide some common customization patterns we've often seen Moderne customers use.
Proprietary Spring Boot upgrade
Many organizations use custom parent projects that extend Spring Boot with organization-specific standards – such as managed dependency versions, additional plugins, or company-wide configuration details. This parent then serves as the foundation for a large set of projects within the organization.
In this instance, you typically need to upgrade the parent project first before rolling out the Spring Boot upgrade to dependent projects.
For the sake of an example let's assume that parent project is called moderne-parent
. The following declarative recipe could be used to upgrade projects using the moderne-parent
:
type: specs.openrewrite.org/v1beta/recipe
name: io.moderne.ModerneSpringBootUpgrade
displayName: ModerneSpringBootUpgrade
description: >
Spring Boot upgrade recipe that takes into account the need to update the
io.moderne:moderne-parent first.
recipeList:
# Update the <parent> version
- org.openrewrite.maven.UpgradeParentVersion:
groupId: io.moderne
artifactId: moderne-parent
newVersion: 1.2.x
# Change the Spring configuration property from `io.moderne.this` to `io.moderne.that`
- org.openrewrite.java.spring.ChangeSpringPropertyValue:
propertyKey: io.moderne.this
newValue: io.moderne.that
# Renames an environment variable used in Kubernetes YAML files from `IO_MODERNE_THIS` to `IO_MODERNE_THAT`
- org.openrewrite.yaml.ChangeValue:
keyPath: $.spec.template.spec.containers[*].env[?(@.name == 'IO_MODERNE_THIS')].name
value: IO_MODERNE_THAT
# Apply the default Spring Boot 3.5 upgrade recipe
- io.moderne.java.spring.boot3.UpgradeSpringBoot_3_5
Implementation steps
Once you've created this recipe, you will need to:
- Run the
io.moderne.java.spring.boot3.UpgradeSpringBoot_3_5
against the parent project to ensure it's updated and properly configured. - Run the custom recipe
io.moderne.ModerneSpringBootUpgrade
against any projects that useio.moderne:moderne-parent
as a parent.
This sequence ensures dependencies are upgraded in the correct order and prevents version conflicts during the upgrade process.