Configuring and using the Visual Studio Code Extension for MTA
Using the migration toolkit for applications extension for Visual Studio Code to identify and resolve migration issues
Abstract
- 1. Introduction to the MTA extension for Microsoft Visual Code
- 2. Installing the MTA extension for Visual Studio Code
- 3. Configuring the IDE settings
- 4. Configuring the MTA profile settings
- 5. Running an application analysis
- 6. Running an application analysis by using a profile
- 7. Reviewing and resolving migration issues
Chapter 1. Introduction to the MTA extension for Microsoft Visual Code
You can migrate and modernize applications by using the migration toolkit for applications (MTA) extension for Microsoft Visual Studio Code.
The MTA extension can perform the following actions:
- Analyze your projects with customizable rulesets.
- Mark issues in the source code.
- Provide guidance to fix the issues.
- Perform automatic code replacement, if possible.
The MTA extension is also compatible with Visual Studio Codespaces, the Microsoft cloud-hosted development environment.
Chapter 2. Installing the MTA extension for Visual Studio Code
You can use the migration toolkit for applications (MTA) Visual Studio (VS) Code plugin to perform a standard application analysis. You can also enable Red Hat Developer Lightspeed for the migration toolkit for applications to use Generative AI (GenAI) capabilities to fix code issues before migrating to target technologies. Note that Developer Lightspeed for MTA is enabled by default. For more information, see Configuring and using Developer Lightspeed for MTA.
Prerequisites
You installed the Java Development Kit (JDK). MTA supports the following JDKs:
- Oracle JDK 17 or later
- Eclipse Temurin™ JDK 17 or later
- OpenJDK 17 or later
- You have 8 GB of RAM available.
-
For macOS installation, you have the value of
maxprocset to2048or greater.
Procedure
- Install the MTA 8.0.1 Visual Studio (VS) Code plugin from the VS Code marketplace.
Chapter 3. Configuring the IDE settings
MTA settings apply to every analysis that you perform by using the Visual Studio (VS) Code extension. The extension settings have the following categories:
- Analysis-related settings
- Debugging and logging settings
- Solution server settings
- Generative AI settings
Procedure
Open the MTA settings by clicking
Extensions>MTA Extension for VSCode>Settings.Alternatively, open the setting by performing the following steps:
-
Type
Ctrl + Shift + PorCmd + Shift + Pon the search bar to open the Command Palette. -
Enter
Preferences: Open Settings (UI). -
Open the settings page by clicing
Extensions>MTA.
-
Type
Configure the following settings:
-
Log level: Set the log level for the MTA binary. The default log level is
debug. The log level increases or decreases the verbosity of logs. - Analyzer path: Specify an MTA custom binary path. If you do not provide a path, Red Hat Developer Lightspeed for MTA uses the default path to the binary.
- Debug:Webview: Enable debug level logging for Webview message handling in VS Code.
-
Log level: Set the log level for the MTA binary. The default log level is
Next steps
Additional resources
Chapter 4. Configuring the MTA profile settings
You can use the Visual Studio (VS) Code plugin to run an analysis to discover issues in the code.
To generate code changes by using the MTA extension, you must configure a profile that contains all the necessary configurations, such as rules and source and target technologies.
Prerequisites
- You configured the VS Code IDE settings. For more information, see Configuring the Red Hat Developer Lightspeed for MTA IDE settings.
- You opened a Java project in your VS Code workspace.
Procedure
Open the
MTA View Analysispage by clicking the book icon on theMTA: Issuespane of the MTA extension.Alternatively, type
Ctrl + Shift + PorCmd + Shift + Pin the search bar to open the Command Palette and enterMTA:Open Analysis View.Click the settings button on the
MTA View Analysispage to configure a profile for your project. TheGet Ready to Analyzepane has the following basic configurations required for an application analysis:- Select profile: Create a profile that you can reuse for one or more analyses.
Configure label selector: A label selector filters rules for analysis based on the source or target technology.
Specify one or more target or source technologies. Red Hat Developer Lightspeed for MTA uses this configuration to determine the rules to apply to a project during the analysis. If you mentioned a new target or a source technology in your custom rule, you can type that name to create and add the new item to the list.
ImportantYou must configure target or source technologies before running an analysis.
- Set rules: Enable default rules and select your custom rule that you want MTA to use for the analysis. You can use the custom rules in addition to the default rules.
Verification
-
After you completed the profile configuration, close the
Get Ready to Analyzepane and run an application analysis.
Next steps
Additional resources
Chapter 5. Running an application analysis
You can run a static code analysis of an application with or without enabling the Generative AI (GenAI) features. The RPC (Remote Procedure Call) server runs the analysis to detect all issues in the code for one or more target technologies which you want to migrate the application to.
Prerequisites
- You opened a Java project in your VS Code workspace.
- You configured an analysis profile on the MTA Analysis View page. For more information, see Configuring the MTA profile settings.
Procedure
- Click the Red Hat Developer Lightspeed for MTA extension and click Open MTA Analysis View.
- Select a profile for the analysis.
- Click Start to start the MTA RPC server.
- Click Run Analysis on the MTA Analysis View page.
Additional resources
Chapter 6. Running an application analysis by using a profile
To run a static code analysis of an application, you can use a profile that is created and managed by your architect in the MTA Hub. The centralized configuration management standardizes the analysis configuration and custom rules across projects to produce a consistent result. This allows the architect to create and manage the necessary profiles, thereby simplifying the lifecycle of analysis configurations and rules. Migrators can run analyses either by using local profile configuration or by using profiles from the Hub.
When you connect to the Hub from your Visual Studio Code instance, MTA downloads the analysis profiles and custom rules present in the Hub to the .konveyor/profiles location in your hard disk. You can use the analysis profile that contains custom rules to perform analyses in your Visual Studio Code IDE environment. If you connect to the Hub, the profile configuration options in your IDE instance are disabled.
Analysis Profile is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
Prerequisites
- You opened a project written in one of the supported languages in your VS Code workspace.
- An architect has configured an analysis profile in the Hub.
Procedure
- Click the Red Hat Developer Lightspeed for MTA extension and click Open Analysis Panel.
-
Click Configure Hub Settings in settings (
).
Configure the following settings on the Hub Configuration page:
- Enable Hub.
- Enter the MTA user interface URL in the Hub URL field.
- Enable Skip SSL certificate verification if you want to connect to your Hub without verifying the local SSL certificate in the host.
- Toggle Enable authentication on to log in to your Hub.
- Enter the username and password credentials of the MTA user interface.
- Enable Solution Server to use the solution server to suggest resolutions for the issues in the source code.
- Enable Profile Sync to sync the profiles with the Hub. MTA periodically downloads the latest version of the profiles from the Hub. MTA does not update the profiles and rules if you do not sync the profiles with the Hub.
- Select a profile from the list on the MTA Analysis View page.
- Click Run Analysis.
Additional resources
Chapter 7. Reviewing and resolving migration issues
You can use the MTA extension icons to prioritize issues based on their severity.
Procedure
- Select a run configuration directory on the left pane.
- Expand its folders to view the Hints generated for each application file.
- Select a hint to view the source code.
- Right-click a hint and select View Details to view the Rule ID and other information.
Prioritize issues based on the following icons, which are displayed next to each hint:
-
: You must fix the issue for a successful migration.
-
: You might need to address the issue during the migration.
-
Resolve issues by editing the code of a file with a hint:
- In the left pane, right-click an issue and select Open Code.
- Make any changes needed to the code and save the file.
- Optional: Right-click the issue and select Mark as Complete or Delete.