Chapter 4. Analyzing Java applications with MTA command-line interface
Depending on your scenario, you can use the Migration Toolkit for Applications (MTA) CLI to perform the following actions:
- Run the analysis against a single application.
Run the analysis against multiple applications:
-
In MTA versions earlier than 7.1.0, you can enter a series of
--analyze
commands, each against an application and each generating a separate report. For more information, see Running the MTA CLI against an application. -
In MTA version 7.1.0 and later, you can use the
--bulk
option to analyze multiple applications at once and generate a single report. Note that this feature is a Developer Preview feature only. For more information, see Analyzing multiple applications.
-
In MTA versions earlier than 7.1.0, you can enter a series of
Starting from MTA version 7.2.0, you can run the application analysis for Java applications in the containerless mode. Note that this option is set by default and is used automatically only if all requirements are met. For more information, see Analyzing an application in the containerless mode.
However, if you want to analyze applications in languages other than Java or, for example, use transformation commands, you still need to use containers.
The analysis output in the disconnected environment usually results in fewer incidents because a dependency analysis does not run accurately without access to Maven.
MTA CLI supports running source code and binary analysis by using analyzer-lsp
. analyzer-lsp
is a tool that evaluates rules by using language providers.
4.1. Analyzing a single application Copy linkLink copied to clipboard!
You can use the Migration Toolkit for Applications (MTA) CLI to perform an application analysis for a single application.
Extracting the list of dependencies from compiled Java binaries is not always possible during the analysis, especially if the dependencies are not embedded within the binary.
Procedure
Optional: List available target technologies for an analysis:
mta-cli analyze --list-targets
$ mta-cli analyze --list-targets
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the analysis:
mta-cli analyze --input <path_to_input> --output <path_to_output> --source <source_name> --target <target_name>
$ mta-cli analyze --input <path_to_input> --output <path_to_output> --source <source_name> --target <target_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the following arguments:
-
--input
: An application to be evaluated. --output
: An output directory for the generated reports.mta-cli analyze
creates the following analysis reports:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
--source
: A source technology for the application migration, for example,weblogic
. -
--target
: A target technology for the application migration, for example,eap8
.
-
Access the generated analysis report:
In the output of the
mta-cli analyze
command, copy a path to theindex.html
analysis report file:Report created: <output_report_directory>/index.html Access it at this URL: file:///<output_report_directory>/index.html
Report created: <output_report_directory>/index.html Access it at this URL: file:///<output_report_directory>/index.html
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Paste the path to the browser of your choice.
Alternatively, press Ctrl and click on the path to the report file.
4.2. Analyzing multiple applications Copy linkLink copied to clipboard!
You can use the Migration Toolkit for Applications (MTA) CLI to perform an application analysis for multiple applications at once and generate a combined report.
Analyzing multiple applications is a Developer Preview feature only. Developer Preview features are not supported by Red Hat in any way and are not functionally complete or production-ready. Do not use Developer Preview features for production or business-critical workloads. Developer Preview features provide early access to upcoming product features in advance of their possible inclusion in a Red Hat product offering, enabling customers to test functionality and provide feedback during the development process. These features might not have any documentation, are subject to change or removal at any time, and testing is limited. Red Hat might provide ways to submit feedback on Developer Preview features without an associated SLA.
Procedure
Run the analysis for multiple applications.
ImportantYou must enter one input per analyze command, but make sure to enter the same output directory for all inputs.
For example, to analyze example applications
A
,B
, andC
, enter the following commands:For input
A
, enter:mta-cli analyze --bulk --input <path_to_input_A> --output <path_to_output_ABC> --source <source_A> --target <target_A>
$ mta-cli analyze --bulk --input <path_to_input_A> --output <path_to_output_ABC> --source <source_A> --target <target_A>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For input
B
, enter:mta-cli analyze --bulk --input <path_to_input_B> --output <path_to_output_ABC> --source <source_B> --target <target_B>
$ mta-cli analyze --bulk --input <path_to_input_B> --output <path_to_output_ABC> --source <source_B> --target <target_B>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For input
C
, enter:mta-cli analyze --bulk --input <path_to_input_C> --output <path_to_output_ABC> --source <source_C> --target <target_C>
$ mta-cli analyze --bulk --input <path_to_input_C> --output <path_to_output_ABC> --source <source_C> --target <target_C>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Access the analysis report. MTA generates a single report, listing all issues that must be resolved before the applications can be migrated.
4.3. Analyzing an application in containerless mode Copy linkLink copied to clipboard!
Starting from MTA 7.2.0, you can perform an application analysis for Java applications by using the MTA CLI that does not require installation of a container runtime.
In MTA 7.2.0 and later, containerless CLI is a default mode. To enable container runtime usage for the analysis of Java applications, you must set the --run-local
flag to false
:
--run-local=false
--run-local=false
The analysis for other applications runs in the container mode automatically
Prerequisites
- You installed the MTA CLI. For more information, see Installing the CLI by using a .zip file.
- You installed Java Development Kit (JDK) version 17 or later.
-
If you use OpenJDK on Red Hat Enterprise Linux (RHEL) or Fedora, you installed the Java
devel
package. - You installed Maven version 3.9.9 or later.
The CLI assumes that a path to the
mvn
binary is correctly registered in the system variable. Therefore, ensure that you addedmvn
to the following variable:-
Path
for Windows. -
PATH
for Linux and macOS.
-
-
You set the
JAVA_HOME
environmental variable. You set the
JVM_MAX_MEM
system variable.NoteIf you do not set
JVM_MAX_MEM
, the analysis might hang because Java might require more memory than the defaultJVM_MAX_MEM
value.For Gradle analysis:
- You installed OpenJDK version 8.
-
You set
$JAVA8_HOME
and it is pointing to the OpenJDK 8 home directory. - Your project has a Gradle wrapper.
Procedure
Optional: Display all
mta-cli analyze
command options:mta-cli analyze --help
$ mta-cli analyze --help
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the application analysis:
mta-cli analyze --overwrite --input <path_to_input> --output <path_to_output> --target <target_source>
$ mta-cli analyze --overwrite --input <path_to_input> --output <path_to_output> --target <target_source>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe
--overwrite
option overwrites the output folder if it exists.
4.4. The analyze command options Copy linkLink copied to clipboard!
The following are the options that you can use together with the mta-cli analyze
command to adjust the command behavior to your needs.
Option | Description |
---|---|
| Analyze open-source libraries. |
|
Set When you disable Maven search, MTA at first tries to determine dependencies from the the JAR file’s POM file (if any). If this method does not succeed, MTA goes through the directory structure to determine dependencies. This method may not produce a reliable dependency classification since the package structure can differ from what is expected by MTA. You may see more number of incidents because some dependencies may be wrongly classified as internal.
By default, |
| The number of lines of source code to include in the output for each incident. The default is 100. |
| A directory for dependencies. |
|
Run default rulesets with analysis. The default is |
|
Display the available flags for the |
| An HTTP proxy string URL. |
| An HTTPS proxy string URL. |
| An expression to select incidents based on custom variables, for example: !package=io.demo.config-utils
|
| A path to the application source code or a binary. |
| A Jaeger endpoint to collect traces. |
| Create analysis and dependence output as a JSON file. |
| Run rules based on specified label selector expression. |
| List all languages in the source application. This flag is not supported for binary applications. |
| List available supported providers. |
| List rules for available migration sources. |
| List rules for available migration targets. |
| A path to the custom Maven settings file to use. |
| An analysis mode. Must be set to either of the following values:
|
| Proxy-excluded URLs (relevant only with proxy). |
| A path to the directory for analysis output. |
| Overwrite the output directory. |
| A filename or directory that contains rule files. |
| Do not generate the static report. |
| A source technology to consider for the analysis. To specify multiple sources, repeat the parameter, for example: --source <source_1> --source <source_2> ...
|
| A target technology to consider for the analysis. To specify multiple targets, repeat the parameter, for example: --target <target_1> --target <target_2> ...
|
| A log level. The default is 4. |
| Do not clean up temporary resources. |