2.3. CLI の実行
シナリオに応じて、Migration Toolkit for Applications (MTA) CLI を使用して、次の方法で分析を実行できます。
- 単一のアプリケーションに対して分析を実行します。
複数のアプリケーションに対して分析を実行します。
-
7.1.0 より前のバージョンの MTA では、一連の
--analyzeコマンドを入力できます。各コマンドはアプリケーションに対して実行し、それぞれ個別のレポートが生成されます。詳細は、アプリケーションに対する MTA CLI の実行 を参照してください。 -
MTA 7.1.0 以降では、
--bulkオプションを使用して複数のアプリケーションを一度に分析し、単一のレポートを生成できます。この機能は開発者プレビュー機能のみであることに注意してください。詳細は、複数のアプリケーションに対して MTA CLI を実行し、単一のレポートを生成する (開発者プレビュー) を参照してください。
-
7.1.0 より前のバージョンの MTA では、一連の
MTA 7.2.0 以降では、コンテナーレスモードでアプリケーション分析を実行できます。このオプションはデフォルトで設定されており、すべての要件が満たされている場合は自動的に使用されることに注意してください。詳細は、コンテナーレス CLI の実行 を参照してください。
2.3.1. 1 つのアプリケーションに対して MTA CLI を実行する リンクのコピーリンクがクリップボードにコピーされました!
Migration Toolkit for Applications (MTA) CLI は、1 つのアプリケーションに対して実行できます。
手順
-
ターミナルを開き、
<MTA_HOME>/ディレクトリーに移動します。 mta-cliスクリプト (Windows の場合はmta-cli.exe) を、適切な引数を指定して実行します。$ ./mta-cli analyze --input <path_to_input> \ --output <path_to_output> --source <source_name> --target <target_source> \-
--input: 評価されるアプリケーション。 -
--output: 生成されたレポートの出力ディレクトリー。 -
--source: アプリケーション移行元のテクノロジー。たとえば、weblogicです。 -
--target: アプリケーション移行先のテクノロジー。たとえば、eap8です。
-
- レポートにアクセスします。
2.3.1.1. MTA コマンドの例 リンクのコピーリンクがクリップボードにコピーされました!
アプリケーションアーカイブでの MTA の実行
次のコマンドでは、JBoss EAP 5 から 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> --source eap5 --target eap7 \
ソースコードに対する MTA の実行
次のコマンドでは、JBoss EAP 8 に移行するために、customer-management というサンプルアプリケーションのソースコードを分析します。
$ <MTA_HOME>/mta-cli analyze --mode source-only --input <path_to_customer-management>
--output <path_to_report_output> --target eap8
cloud-readiness ルールの実行
次のコマンドでは、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.3.2. 複数のアプリケーションに対して MTA CLI を実行し、1 つのレポートを生成する (開発者プレビュー) リンクのコピーリンクがクリップボードにコピーされました!
複数のアプリケーションに対して Migration Toolkit for Applications (MTA) CLI を実行し、1 つに結合されたレポートを生成できるようになりました。これにより、時間を節約でき、移行に向けて一連のアプリケーションを準備する方法をより適切に把握できます。
この機能は現在、開発者プレビュー機能です。
1 つ以上のアプリケーションに対する CLI の実行は、開発者プレビュー機能です。開発者プレビュー機能は、Red Hat ではいかなる形でもサポートされていません。また、機能的には完全ではなく、実稼働環境に対応していません。本番環境またはビジネスクリティカルなワークロードには、開発者プレビュー機能を使用しないでください。開発者プレビュー機能は、Red Hat 製品オファリングに含まれる可能性がある前に、今後の製品機能への早期アクセスを提供し、お客様が機能をテストし、開発プロセス中にフィードバックを提供できるようにします。これらの機能にはドキュメントがない可能性があり、いつでも変更または削除される可能性があり、テストは制限されています。Red Hat は、関連する SLA なしで、開発者プレビュー機能に関するフィードバックを送信する方法を提供する場合があります。
手順
-
ターミナルを開き、
<MTA_HOME>/ディレクトリーに移動します。 mta-cliスクリプト (Windows の場合はmta-cli.exe) を、適切な引数を指定して実行します。analyzeコマンドごとに 1 つの入力を指定しますが、すべての入力に対して同じ出力ディレクトリーを指定します。たとえば、アプリケーション A、B、C を分析するには、次のように指定します。入力 A について、次のコマンドを指定します。
$ ./mta-cli analyze --bulk --input=<path_to_input_A> --output=<path_to_output_ABC> --source <source_A> --target <target_A>-
--input: 評価されるアプリケーション。 -
--output: 生成されたレポートの出力ディレクトリー。 -
--source: アプリケーション移行元のテクノロジー。たとえば、weblogicです。 -
--target: アプリケーション移行先のテクノロジー。たとえば、eap8です。
-
入力 B について、次のコマンドを指定します。
$ ./mta-cli analyze --bulk --input=<path_to_input_B> --output=<path_to_output_ABC> --source <source_B> --target <target_B>入力 C について、次のコマンドを指定します。
$ ./mta-cli analyze --bulk --input=<path_to_input_C> --output=<path_to_output_ABC> --source <source_C> --target <target_C>MTA によって、アプリケーションを移行する前に解決する必要があるすべての問題をリストした 1 つのレポートが生成されます。
- レポートにアクセスします。
2.3.3. コマンドラインを使用して分析を実行する リンクのコピーリンクがクリップボードにコピーされました!
Analyze は、analyzer-lsp ツールを使用してソースコードとバイナリー分析の実行をサポートします。analyzer-lsp はプロバイダーのルールを評価し、ルールの一致を判断します。
特に依存関係がバイナリー内に組み込まれていない場合は、分析中に依存関係のリストを、コンパイルされた Java バイナリーから常に展開できるわけではありません。
アプリケーションのソースコード分析を実行するには、次のコマンドを実行します。
mta-cli analyze --input=<path_to_source_code> --output=<path_to_output_directory>
すべてのフラグ:
Analyze application source code
Usage:
mta-cli analyze [flags]
Flags:
--analyze-known-libraries Analyze known open-source libraries.
--context-lines (int) Number of lines of source code to
include in the output for each
incident (default: `100`).
-d, --dependency-folders (stringArray) Directory for dependencies.
--enable-default-rulesets Run default rulesets with analysis
(default: `true`).
-h, --help Help for analyze.
--http-proxy (string) HTTP proxy string URL.
--https-proxy (string) HTTPS proxy string URL.
--incident-selector (string) An expression to select incidents
based on custom variables.
Example:
!package=io.demo.config-utils
-i, --input (string) Path to application source code or
a binary.
--jaeger-endpoint (string) Jaeger endpoint to collect traces.
--json-output Create analysis and dependency
output as JSON.
--list-sources List available migration sources.
--list-targets List available migration targets.
-l, --label-selector (string) Run rules based on specified label
selector expression.
--maven-settings (string) Path to the 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`).
--no-proxy (string) Proxy-excluded URLs
(relevant only with proxy).
-o, --output (string) Path to the directory for analysis
output.
--overwrite Overwrite output directory.
--rules (stringArray) Filename or directory containing
rule files.
--run-local Run analysis directly on
local system without containers
(for Java and Maven).
Starting from MTA 7.2.0,
containerless CLI is the default
mode (`--run-local=true`).
You can enable container runtime
usage by setting `--run-local` to `false`.
--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.
上記のフラグのリストには --bulk フラグは含まれていません。このフラグは開発者プレビュー機能の一部として提供されているためです。この機能については、CLI で複数のアプリケーションを分析するときに 1 つのレポートを提供するためのサポート で説明されています。
使用例:
- 分析を実行するサンプルアプリケーションを取得します。
利用可能なターゲットテクノロジーをリストします。
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は、Issues レポートが含まれるファイルです。 -
static-reportには、静的 HTML レポートが含まれています。 -
dependencies.yamlには、依存関係レポートが含まれています。
-
2.3.4. コンテナーレス CLI の実行 リンクのコピーリンクがクリップボードにコピーされました!
MTA 7.2.0 以降では、コンテナーランタイムのインストールを必要としない MTA CLI を使用して、Java アプリケーションのアプリケーション分析を実行できます。
MTA 7.2.0 以降では、コンテナーレス CLI がデフォルトモードです。コンテナーランタイムの使用を有効にするには、--run-local フラグを false に設定する必要があります。
--run-local=false
前提条件
- システムに OpenJDK バージョン 17 以降がインストールされている。
- システムに Maven バージョン 3.9.9 以降がインストールされている。
CLI では、
mvnバイナリーへのパスがシステム変数に正しく登録されていることを前提としている。したがって、次の変数にmvnが追加されていることを確認してください。-
Windows の
Path。 -
Linux および macOS の
PATH。
-
Windows の
-
JAVA_HOME環境変数が設定されている。 JVM_MAX_MEMシステム変数が設定されている。注記JVM_MAX_MEMを設定しないと、分析がハングする可能性があります。
Linux の手順
zip ファイル全体を ~/.kantra に展開した後、そのパスを $PATH 変数に追加します。
mta-cli バイナリーを /usr/bin に移動するには root 権限が必要ですが、そのパスを $PATH 変数に追加するには root 権限は必要ありません。
依存関係の zip ファイルを
~/.kantraに抽出するには、次のコマンドを実行します。unzip $HOME/mta-cli.<os>.<arch>.zip -d $HOME/.kantraシステム全体のバイナリーとして追加するか、グローバル
$PATH変数に追加します。たとえば、
sudoを使用して、mta-cliバイナリーをシステム全体のバイナリーとして/usr/binに追加するには、次を実行します。sudo mv ~/.kantra/mta-cli /usr/bin/たとえば、グローバル
$PATH変数に追加するには、次を実行します。export PATH=$HOME/.kantra:$PATH
注記CLI は、分析を実行するディレクトリーに要件を移動して実行できます。分析中、CLI は最初にこのディレクトリーで要件をチェックし、要件が見つからない場合は
$HOME/.kantraディレクトリーで検索します。オプション: すべての
mta-cli analyzeコマンドオプションを表示します。mta-cli analyze --helpアプリケーション分析を実行します。
$ mta-cli analyze --overwrite --input <path_to_input> --output <path_to_output> --target <target_source>コマンド引数は次のものを表します。
-
--overwrite: 出力フォルダーが存在する場合は上書きします。 -
--input: 分析するアプリケーション。 -
--output: 生成されたレポートの出力ディレクトリー。 -
--target: アプリケーション移行のターゲットテクノロジー (例:eap8)。
-
2.3.5. コマンドラインを使用して変換を実行する リンクのコピーリンクがクリップボードにコピーされました!
変換を使用して、以下のアクションを実行できます。
-
transform openrewriteコマンドを使用して、Java アプリケーションのソースコードを変換します。 -
transform rulesコマンドを使用して、XML ルールを YAML ルールに変換します。
変換を実行するには、コンテナーランタイムを設定する必要があります。詳細は、Podman を使用して CLI をインストールする を参照してください。
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 clean up temporary resources
Use "mta-cli transform [command] --help" for more information about a command.
2.3.5.1. OpenRewrite リンクのコピーリンクがクリップボードにコピーされました!
openrewrite サブコマンドを使用すると、ソースコードに対して OpenRewrite レシピを実行できます。
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 clean up temporary resources
アプリケーションのソースコードに対して transform openrewrite を実行するには、次のコマンドを実行します。
mta-cli transform openrewrite --input=<path/to/source/code> --target=<exactly_one_target_from_the_list>
transform overwrite コマンドの実行に使用できるターゲットは 1 つだけです。
2.3.5.2. ルール リンクのコピーリンクがクリップボードにコピーされました!
transform コマンドの rules サブコマンドを使用して、mta XML ルールを analyzer-lsp YAML ルールに変換できます。ルールを変更するために、rules サブコマンドは windup-shim ツールを使用します。
analyzer-lsp はプロバイダーのルールを評価し、ルールの一致を判断します。
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)
アプリケーションのソースコードで transform rules を実行するには、以下を実行します。
mta-cli transform rules --input=<path/to/xmlrules> --output=<path/to/output/dir>
使用例:
- ソースコードを変換するサンプルアプリケーションを取得します。
利用可能な OpenRewrite レシピを表示します。
mta-cli transform openrewrite --list-targetsサンプルアプリケーションでレシピを実行します。
mta-cli transform openrewrite --input=<path-to/jakartaee-duke> --target=jakarta-importsjakartaee-dukeアプリケーションのソースコードの差分を調べて、変換を確認します。
2.3.5.3. 利用可能な OpenRewrite レシピ リンクのコピーリンクがクリップボードにコピーされました!
| 移行パス | 目的 | rewrite.configLocation | activeRecipes |
|---|---|---|---|
| Java EE から Jakarta EE |
|
|
|
| Java EE から Jakarta EE | ブートストラップファイルの名前を変更する |
|
|
| Java EE から Jakarta EE |
|
|
|
| Spring Boot から Quarkus |
|
|
|