Chapter 6. Performing a transformation with the MTA command-line interface
You can use transformation to transform Java applications source code by using the transform openrewrite command.
Performing transformation requires the container runtime to be configured.
6.1. Transforming applications source code Copy linkLink copied to clipboard!
To update Java libraries or frameworks, for example, javax or Spring Boot, you can transform Java application source code by using the transform openrewrite command. The openrewrite subcommand allows running OpenRewrite recipes on source code.
You can only use a single target to run the transform overwrite command.
Prerequisites
- You configured the container runtime.
Procedure
Display the available
OpenRewriterecipes:mta-cli transform openrewrite --list-targets
$ mta-cli transform openrewrite --list-targetsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Transform the application source code:
mta-cli transform openrewrite --input=<path_to_source_code> --target=<target_from_the_list>
$ mta-cli transform openrewrite --input=<path_to_source_code> --target=<target_from_the_list>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Inspect the target application source code
diffto see the transformation.
6.2. Available OpenRewrite recipes Copy linkLink copied to clipboard!
The following are the OpenRewrite recipes that you can use for transforming application source code.
| Migration path | Purpose | The rewrite.config file location | Active recipes |
|---|---|---|---|
| Java EE to Jakarta EE |
Replace import of
Replace |
|
|
| Java EE to Jakarta EE | Rename bootstrapping files. |
|
|
| Java EE to Jakarta EE |
Transform the |
|
|
| Spring Boot to Quarkus |
Replace |
|
|
6.3. The openrewrite command options Copy linkLink copied to clipboard!
The following are the options that you can use together with the mta-cli transform openrewrite command to adjust the command behavior to your needs.
| Option | Description |
|---|---|
|
|
A target goal. The default is |
|
|
Display all |
|
| A path to the application source code directory. |
|
| List all available OpenRewrite recipes. |
|
| A path to a custom Maven settings file. |
|
| A target OpenRewrite recipe. |
|
|
A log level. The default is |
|
| Do not clean up temporary resources. |