2.2. 运行 CLI
您可以针对您的应用程序运行 MTA。
流程
-
打开一个终端,再进入 <
MTA_HOME>/目录。 为 Windows 执行
mta-cli脚本或mta-cli.exe,并指定适当的参数:$ ./mta-cli analyze --input /path/to/jee-example-app-1.0.0.ear \ --output /path/to/output --source weblogic --target eap6 \-
--input:要评估的应用程序。 -
--output:所生成的报告的输出目录。 -
--source:应用程序迁移的源技术。
-
- 访问报告。
2.2.1. MTA 命令示例 复制链接链接已复制到粘贴板!
在应用程序存档中运行 MTA
以下命令分析 jee-example-app-1.0.0.ear 示例 EAR 存档,用于从 JBoss EAP 5 迁移到 JBoss EAP 7:
$ <MTA_HOME>/mta-cli analyze \
--input /path/to/jee-example-app-1.0.0.ear \
--output /path/to/report-output/ --source eap5 --target eap7 \
在源代码上运行 MTA
以下命令分析 Migrate -booking-5.2 示例源代码以迁移到 JBoss EAP 6。
$ <MTA_HOME>/mta-cli analyze --mode source-only --input /path/to/seam-booking-5.2/ \
--output /path/to/report-output/ --target eap6 --packages org.jboss.seam
运行云就绪规则
以下命令分析用于迁移到 JBoss EAP 7 的 jee-example-app-1.0.0.ear 示例 EAR 存档。它还评估了云就绪情况:
$ <MTA_HOME>/mta-cli analyze --input /path/to/jee-example-app-1.0.0.ear \
--output /path/to/report-output/ \
--target eap7
2.2.2. 使用命令行执行分析 复制链接链接已复制到粘贴板!
分析 允许使用 分析器-lsp 运行源代码和二进制分析。
要对应用程序源代码运行分析,请运行以下命令:
mta-cli analyze --input=<path/to/source/code> --output=<path/to/output/dir>
所有标记:
Analyze application source code
Usage:
mta-cli analyze [flags]
Flags:
--analyze-known-libraries analyze known open-source libraries
-h, --help help for analyze
-i, --input string path to application source code or a binary
--json-output create analysis and dependency output as json
--list-sources list rules for available migration sources
--list-targets list rules for available migration targets
-l, --label-selector string run rules based on specified label selector expression
--maven-settings string path to a custom maven settings file to use
--overwrite overwrite output directory
--skip-static-report do not generate the static report
-m, --mode string analysis mode. Must be one of 'full' or 'source-only' (default "full")
-o, --output string path to the directory for analysis output
--rules stringArray filename or directory containing rule files
--skip-static-report do not generate the static report
-s, --source string source technology to consider for analysis. To specify multiple sources, repeat the parameter: --source <source_1> --source <source_2> etc.
-t, --target string target technology to consider for analysis. To specify multiple targets, repeat the parameter: --target <target_1> --target <target_2> etc.
Global Flags:
--log-level uint32 log level (default 4)
--no-cleanup do not cleanup temporary resources
使用示例
- 获取要运行分析的示例应用。
列出可用的目标技术。
mta-cli analyze --list-targets使用指定的目标技术运行分析,如
cloud-readiness。mta-cli analyze --input=<path-to/example-applications/example-1> --output=<path-to-output-dir> --target=cloud-readiness在指定的输出路径中创建了几个分析报告:
$ ls ./output/ -1 analysis.log dependencies.yaml dependency.log output.yaml static-report
output.yaml 是包含问题报告的文件。
static-report 包含静态 HTML 报告。
dependencies.yaml 包含依赖项报告。
2.2.3. 使用命令行执行转换 复制链接链接已复制到粘贴板!
转换有两个子命令 - openrewrite 和 rules。
Transform application source code or mta XML rules
Usage:
mta-cli transform [flags]
mta-cli transform [command]
Available Commands:
openrewrite Transform application source code using OpenRewrite recipes
rules Convert XML rules to YAML
Flags:
-h, --help help for transform
Global Flags:
--log-level uint32 log level (default 4)
--no-cleanup do not cleanup temporary resources
Use "mta-cli transform [command] --help" for more information about a command.
2.2.3.1. OpenRewrite 复制链接链接已复制到粘贴板!
openrewrite sub 命令允许在源代码上运行 OpenRewrite recipes。
Transform application source code using OpenRewrite recipes
Usage:
mta-cli transform openrewrite [flags]
Flags:
-g, --goal string target goal (default "dryRun")
-h, --help help for openrewrite
-i, --input string path to application source code directory
-l, --list-targets list all available OpenRewrite recipes
-s, --maven-settings string path to a custom maven settings file to use
-t, --target string target openrewrite recipe to use. Run --list-targets to get a list of packaged recipes.
Global Flags:
--log-level uint32 log level (default 4)
--no-cleanup do not cleanup temporary resources
要在应用程序源代码上运行 转换 openrewrite,请运行以下命令:
mta-cli transform openrewrite --input=<path/to/source/code> --target=<exactly_one_target_from_the_list>
您只能使用单个目标来运行 转换覆盖 命令。
2.2.3.2. 规则 复制链接链接已复制到粘贴板!
rules 子命令允许使用 windup-shim 将 mta XML 规则转换为分析器-lsp YAML 规则。
Convert XML rules to YAML
Usage:
mta-cli transform rules [flags]
Flags:
-h, --help help for rules
-i, --input stringArray path to XML rule file(s) or directory
-o, --output string path to output directory
Global Flags:
--log-level int log level (default 5)
要在应用程序源代码上运行 转换规则,请运行以下命令:
mta-cli transform rules --input=<path/to/xmlrules> --output=<path/to/output/dir>
使用示例
- 获取示例应用程序来转换源代码。
查看可用的 OpenRewrite recipes。
mta-cli transform openrewrite --list-targets在示例应用程序上运行方法。
mta-cli transform openrewrite --input=<path-to/jakartaee-duke> --target=jakarta-imports检查
jakartaee-duke应用程序源代码 diff 以查看转换
2.2.3.3. 可用的 OpenRewrite recipes 复制链接链接已复制到粘贴板!
| 迁移路径 | 用途 | rewrite.configLocation | activeRecipes |
|---|---|---|---|
| Java EE 到 Jakarta EE |
使用对等的
将 |
|
|
| Java EE 到 Jakarta EE | 重命名 bootstrap 文件 |
|
|
| Java EE 到 Jakarta EE |
转换 |
|
|
| Spring Boot 到 Quarkus |
在文件中替换 |
|
|