Class MigrationEngine
The engine never rewrites a whole file. It parses a document, locates the exact source span of each deprecated key and replaces only those spans, so line terminators, indentation, comments, quoting and the presence or absence of a trailing newline all survive untouched, and the resulting diff shows only the keys that actually changed.
A key is rewritten only when doing so is provably safe. Anything else - a replacement whose value type changed, a target that already exists, several keys collapsing onto one replacement, or a YAML key whose replacement belongs under a different parent - is reported for manual action rather than guessed at.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(MigrationPlan plan) Writes every pending change from a plan.Analyses the given files without modifying anything.plan(Path rootDir, List<Path> files, DeprecationCatalog catalog, String springBootVersion, UnknownKeyOptions unknownKeys) Analyses the given files without modifying anything.
-
Constructor Details
-
MigrationEngine
public MigrationEngine()
-
-
Method Details
-
plan
public MigrationPlan plan(Path rootDir, List<Path> files, DeprecationCatalog catalog, String springBootVersion) Analyses the given files without modifying anything.- Parameters:
rootDir- the project root, used to render relative pathsfiles- the configuration files to analysecatalog- the deprecations known to the project's classpathspringBootVersion- the detected Spring Boot version, ornull- Returns:
- the plan describing every finding and every pending write
-
plan
public MigrationPlan plan(Path rootDir, List<Path> files, DeprecationCatalog catalog, String springBootVersion, UnknownKeyOptions unknownKeys) Analyses the given files without modifying anything.- Parameters:
rootDir- the project directory that paths are reported relative tofiles- the configuration files to inspectcatalog- the deprecations known to the project classpathspringBootVersion- the detected Spring Boot version, ornullunknownKeys- how to treat keys the metadata does not describe- Returns:
- the plan describing every finding and every pending write
-
apply
Writes every pending change from a plan.Each file is written to a sibling temporary file and then moved into place, so an interrupted run cannot leave a half-written configuration file behind.
- Parameters:
plan- the plan to apply- Throws:
IOException- if a file cannot be written
-