Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 2. Installing and Running the CLI

download PDF

2.1. Installing the CLI

You can install the CLI on Linux, Windows, or macOS operating systems.

Prerequisites

  • Red Hat Container Registry Authentication for registry.redhat.io. Red Hat distributes container images from registry.redhat.io, which requires authentication. For more details, see Red Hat Container Registry Authentication.
  • Podman must be installed

    Podman

    Podman is a daemonless, open source, Linux-native tool designed to make it easy to find, run, build, share, and deploy applications using Open Containers Initiative (OCI) Containers and Container Images. Podman provides a command-line interface (CLI) familiar to anyone who has used the Docker Container Engine. For more information on installing and using Podman, see Podman installation instructions.

2.1.1. Installing the CLI .zip file

Procedure

To install using the downloadable .zip file:

  1. Navigate to the MTA Download page and download the OS-specific CLI file or the src file:

    • mta-7.0.3-cli-linux.zip
    • mta-7.0.3-cli-macos.zip
    • mta-7.0.3-cli-windows.zip
    • mta-7.0.3-cli-src.zip
  2. Extract the .zip file to a directory of your choice. The .zip file extracts a single binary, called mta-cli.

    When you encounter <MTA_HOME> in this guide, replace it with the actual path to your MTA installation.

2.1.2. Installing the CLI using Podman

Prerequisites

  • Red Hat Container Registry Authentication for registry.redhat.io. Red Hat distributes container images from registry.redhat.io, which requires authentication. For more details, see Red Hat Container Registry Authentication.

Procedure

To install using podman pull:

  1. To use Podman to authenticate to registry.redhat.io:

    podman login registry.redhat.io
    Username: <username>
    Password: <***********>
  2. Issue:

    podman cp $(podman create registry.redhat.com/mta-toolkit/mta-mta-cli-rhel9:{ProductVersion}):/usr/local/bin/mta-cli ./

    This command will copy the binary PATH for system-wide use.

    Warning

    Although installation using Podman is possible, downloading and installing the .zip file is the preferred installation.

2.1.3. CLI known issues

Limitations with Podman on Microsoft Windows

The CLI is built and distributed with support for Microsoft Windows.

However, when running any container image based on Red Hat Enterprise Linux 9 (RHEL9) or Universal Base Image 9 (UBI9), the following error can be returned when starting the container:

Fatal glibc error: CPU does not support x86-64-v2

This error is caused because Red Hat Enterprise Linux 9 or Universal Base Image 9 container images must be run on a CPU architecture that supports x86-64-v2.

For more details, see (Running Red Hat Enterprise Linux 9 (RHEL) or Universal Base Image (UBI) 9 container images fail with "Fatal glibc error: CPU does not support x86-64-v2").

CLI runs the container runtime correctly. However, different container runtime configurations are not supported.

Although unsupported, you can run CLI with Docker instead of Podman, which would resolve this issue.

To achieve this, you replace the PODMAN_BIN path with the path to Docker.

For example, if you experience this issue, instead of issuing:

PODMAN_BIN=/usr/local/bin/docker mta-cli analyze

You replace PODMAN_BIN with the path to Docker:

<Docker Root Dir>=/usr/local/bin/docker mta-cli analyze

While this is not supported, it would allow you to explore CLI while you work to upgrade your hardware or move to hardware that supports x86_64-v2.

2.2. Running the CLI

You can run MTA against your application.

Procedure

  1. Open a terminal and navigate to the <MTA_HOME>/ directory.
  2. Execute the mta-cli script, or mta-cli.exe for Windows, and specify the appropriate arguments:

    $ ./mta-cli analyze --input /path/to/jee-example-app-1.0.0.ear \
        --output /path/to/output --source weblogic --target eap6 \
    • --input: The application to be evaluated.
    • --output: The output directory for the generated reports.
    • --source: The source technology for the application migration.
  3. Access the report.

2.2.1. MTA command examples

Running MTA on an application archive

The following command analyzes the jee-example-app-1.0.0.ear example EAR archive for migrating from JBoss EAP 5 to 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 \
Running MTA on source code

The following command analyzes the seam-booking-5.2 example source code for migrating to 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
Running cloud-readiness rules

The following command analyzes the jee-example-app-1.0.0.ear example EAR archive for migrating to JBoss EAP 7. It also evaluates for cloud readiness:

$ <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. Performing analysis using the command line

Analyze allows running source code and binary analysis using analyzer-lsp.

To run analysis on application source code, run the following command:

mta-cli analyze --input=<path/to/source/code> --output=<path/to/output/dir>

All flags:

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

Usage example

  1. Get an example application to run analysis on.
  2. List available target technologies.

    mta-cli analyze --list-targets
  3. Run an analysis with a specified target technology, for example cloud-readiness.

    mta-cli analyze --input=<path-to/example-applications/example-1> --output=<path-to-output-dir> --target=cloud-readiness
  4. Several analysis reports are created in your specified output path:

    $ ls ./output/ -1
    analysis.log
    dependencies.yaml
    dependency.log
    output.yaml
    static-report

output.yaml is the file that contains the issues report.

static-report contains the static HTML report.

dependencies.yaml contains a dependencies report.

2.2.3. Performing transformation using the command line

Transform has two sub commands - openrewrite and 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

The openrewrite sub command allows running OpenRewrite recipes on source code.

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

To run transform openrewrite on application source code, run the following command:

mta-cli transform openrewrite --input=<path/to/source/code> --target=<exactly_one_target_from_the_list>

Note

You can only use a single target to run the transform overwrite command.

2.2.3.2. Rules

The rules sub command allows converting mta XML rules to analyzer-lsp YAML rules using windup-shim.

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)

To run transform rules on application source code, run the following:

mta-cli transform rules --input=<path/to/xmlrules> --output=<path/to/output/dir>

Usage example

  1. Get an example application to transform source code.
  2. View the available OpenRewrite recipes.

    mta-cli transform openrewrite --list-targets
  3. Run a recipe on the example application.

    mta-cli transform openrewrite --input=<path-to/jakartaee-duke> --target=jakarta-imports

    Inspect the jakartaee-duke application source code diff to see the transformation

2.2.3.3. Available OpenRewrite recipes

Table 2.1. Available OpenRewrite recipes
Migration pathPurposerewrite.configLocationactiveRecipes

Java EE to Jakarta EE

Replace import of javax packages with equivalent jakarta packages

Replace javax artifacts, declared within pom.xml files, with the jakarta equivalents

<MTA_HOME>/rules/openrewrite/jakarta \ /javax/imports/rewrite.yml

org.jboss.windup.JavaxToJakarta

Java EE to Jakarta EE

Rename bootstrapping files

<MTA_HOME>/rules/openrewrite/jakarta \ /javax/bootstrapping/rewrite.yml

org.jboss.windup.jakarta.javax. \ BootstrappingFiles

Java EE to Jakarta EE

Transform persistence.xml configuration

<MTA_HOME>/rules/openrewrite/jakarta \ /javax/xml/rewrite.yml

org.jboss.windup.javax-jakarta. \ PersistenceXML

Spring Boot to Quarkus

Replace spring.jpa.hibernate.ddl-auto property within files matching application*.properties

<MTA_HOME>/rules/openrewrite/quarkus \ /springboot/properties/rewrite.yml

org.jboss.windup.sb-quarkus.Properties

2.3. Accessing reports

When you run the Migration Toolkit for Applications, a report is generated in the <OUTPUT_REPORT_DIRECTORY> that you specify using the --output argument in the command line.

The output directory contains the following files and subdirectories:

<OUTPUT_REPORT_DIRECTORY>/
├── index.html          // Landing page for the report
├── <EXPORT_FILE>.csv   // Optional export of data in CSV format
├── archives/           // Archives extracted from the application
├── mavenized/          // Optional Maven project structure
├── reports/            // Generated HTML reports
├── stats/              // Performance statistics

Procedure

  1. Obtain the path of the index.html file of your report from the output that appears after you run MTA:

    Report created: <OUTPUT_REPORT_DIRECTORY>/index.html
                  Access it at this URL: file:///<OUTPUT_REPORT_DIRECTORY>/index.html
  2. Open the index.html file by using a browser.

    The generated report is displayed.

Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.