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

The following are the prerequisites for the Migration Toolkit for Runtimes (MTR) installation:

  • Java Development Kit (JDK) is installed. MTR supports the following JDKs:

    • OpenJDK 11
    • OpenJDK 17
    • Oracle JDK 11
    • Oracle JDK 17
    • Eclipse Temurin™ JDK 11
    • Eclipse Temurin™ JDK 17
  • 8 GB RAM
  • macOS installation: the value of maxproc must be 2048 or greater.

Procedure

  1. Navigate to the MTR Download page and download the Migration Toolkit CLI file.
  2. Extract the .zip file to a directory of your choice.

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

2.2. Running the CLI

You can run MTR against your application.

Procedure

  1. Open a terminal and navigate to the <MTR_HOME>/bin/ directory.
  2. Execute the windup-cli script, or windup-cli.bat for Windows, and specify the appropriate arguments:

    $ ./windup-cli --input /path/to/jee-example-app-1.0.0.ear \
        --output /path/to/output --source weblogic --target eap:6 \
        --packages com.acme org.apache
    • --input: The application to be evaluated.
    • --output: The output directory for the generated reports.
    • --source: The source technology for the application migration.
    • --target: The target technology for the application migration.
    • --packages: The packages to be evaluated. This argument is highly recommended to improve performance.
  3. Access the report.

2.2.1. MTR command examples

Running MTR on an application archive

The following command analyzes the com.acme and org.apache packages of the jee-example-app-1.0.0.ear example EAR archive for migrating from JBoss EAP 5 to JBoss EAP 7:

$ <MTR_HOME>/bin/windup-cli \

    --input /path/to/jee-example-app-1.0.0.ear \
    --output /path/to/report-output/ --source eap:5 --target eap:7 \
    --packages com.acme org.apache
Running MTR on source code

The following command analyzes the org.jboss.seam packages of the seam-booking-5.2 example source code for migrating to JBoss EAP 6.

$ <MTR_HOME>/bin/windup-cli --sourceMode --input /path/to/seam-booking-5.2/ \

    --output /path/to/report-output/ --target eap:6 --packages org.jboss.seam
Running cloud-readiness rules

The following command analyzes the com.acme and org.apache packages of the jee-example-app-1.0.0.ear example EAR archive for migrating to JBoss EAP 7. It also evaluates for cloud readiness:

$ <MTR_HOME>/windup-cli --input /path/to/jee-example-app-1.0.0.ear \

    --output /path/to/report-output/ \
    --target eap:7 --target cloud-readiness --packages com.acme org.apache
Overriding MTR properties

To override the default Fernflower decompiler, pass the -Dwindup.decompiler argument on the command line. For example, to use the Procyon decompiler, use the following syntax:

$ <MTR_HOME>/bin/windup-cli -Dwindup.decompiler=procyon \
    --input <INPUT_ARCHIVE_OR_DIRECTORY> --output <OUTPUT_REPORT_DIRECTORY> \
    --target <TARGET_TECHNOLOGY> --packages <PACKAGE_1> <PACKAGE_2>

2.2.2. MTR CLI Bash completion

The MTR CLI provides an option to enable Bash completion for Linux systems, allowing the MTR command-line arguments to be auto completed by pressing the Tab key when entering the commands. For instance, when Bash completion is enabled, entering the following displays a list of available arguments.

$ <MTR_HOME>/bin/windup-cli [TAB]
Enabling Bash completion

To enable Bash completion for the current shell, execute the following command:

$ source <MTR_HOME>/bash-completion/windup-cli
Enabling persistent Bash completion

The following commands allow Bash completion to persist across restarts:

  • To enable Bash completion for a specific user across system restarts, include the following line in that user’s ~/.bashrc file.

    source <MTR_HOME>/bash-completion/windup-cli
  • To enable Bash completion for all users across system restarts, copy the Migration Toolkit for Runtimes CLI Bash completion file to the /etc/bash_completion.d/ directory as the root user.

    # cp <MTR_HOME>/bash-completion/windup-cli /etc/bash_completion.d/

2.2.3. Accessing MTR help

To see the complete list of available arguments for the windup-cli command, open a terminal, navigate to the <MTR_HOME> directory, and execute the following command:

$ <MTR_HOME>/bin/windup-cli --help

2.2.4. Using OpenRewrite recipes

Important

OpenRewrite recipe support is provided as Technology Preview only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend to use them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

See Technology Preview features support scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features.

You can refactor the source code of Java applications by using OpenRewrite recipes with the MTR CLI.

For example, the OpenRewrite recipe org.jboss.windup.JavaxToJakarta renames imported javax packages to their jakarta equivalents.

Procedure

  1. Run windup-cli, specifying the recipe name, the path to the configuration file, and the application:

    $ ./windup-cli --openrewrite --input </path/to/source/project> \
      "-Drewrite.configLocation=<path/to/rewrite.yaml>"  \
      "-DactiveRecipes=<recipe_name>" --goal dryRun
    • "-DactiveRecipes=<recipe name>": Specify the OpenRewrite recipe, for example, org.jboss.windup.JavaxToJakarta.
    • --input: Specify the application to be refactored. The application must be the top of the source code project containing a Maven Project Object Model (POM) XML file, pom.xml.
    • -Drewrite.configLocation=<path/to/rewrite.yaml> : The location of the rewrite.yaml configuration file to use. The shipped rewrite.yaml configuration files are located in your <MTR_HOME>/rules/openrewrite subfolder, for example," -Drewrite.configLocation=<MTR_HOME>/rules/openrewrite/jakarta/javax/imports/rewrite.yaml".
    • "-DactiveRecipes=<recipe name>": Specify the OpenRewrite recipe, for example, org.jboss.windup.JavaxToJakarta.

      You can include more than one recipe by specifying each in the activeRecipes parameter. For example, to include the recipes org.jboss.windup.JavaxInjectToJakartaInject and org.jboss.windup.JavaxEjbToJakartaEjb", enter the following for "-DactiveRecipes=<recipe name>":

        "-DactiveRecipes=org.jboss.windup.JavaxInjectToJakartaInject, \
          org.jboss.windup.JavaxEjbToJakartaEjb"
    • --goal: Optional: The OpenRewrite Maven goal to run.

      • dryRun : The script returns a list of proposed changes. Ignore the "Run 'mvn rewrite:run' to apply the recipes" message.
      • run: The script applies the changes.
  2. Run windup-cli with --goal run to apply the recipe:

    $ ./windup-cli --openrewrite --input </path/to/source/project> \
      "-Drewrite.configLocation=<path/to/rewrite.yaml>"  \
      "-DactiveRecipes=<recipe_name>" --goal run

2.2.4.1. 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

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

org.jboss.windup.JavaxToJakarta

Java EE to Jakarta EE

Rename bootstrapping files

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

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

Java EE to Jakarta EE

Transform persistence.xml configuration

<MTR_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

<MTR_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 Runtimes, 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 MTR:

    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.