Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This quickstart shows you how to upgrade a Java project using GitHub Copilot App Modernization - upgrade for Java.
Prerequisites
A GitHub account with GitHub Copilot enabled, using a paid GitHub Copilot subscription plan - GitHub Copilot Pro, GitHub Copilot Pro+, GitHub Copilot Business, or GitHub Copilot Enterprise.
The latest version of Visual Studio Code.
The latest version of the GitHub Copilot extension in Visual Studio Code.
GitHub Copilot App Modernization extension pack. For install instructions, see the next section.
This extension pack bundles the following two extensions:
App Modernization doesn't require Java in your local environment. However, to build your project successfully, install the correct version of Java and Maven. We recommend the Microsoft Build of OpenJDK and Maven.
Installed versions of both the source and target JDKs.
A Git-managed Java project using Maven or Gradle.
For Maven-based projects: access to the public Maven Central repository.
Make sure "chat.extensionTools.enabled" is set to true in the Visual Studio Code settings. This setting might be controlled by your organization.
Note
If you're using Gradle, only the Gradle wrapper version 5+ is supported. The Kotlin DSL isn't supported.
Sign in to use Copilot and then install the required extension
To use GitHub Copilot, sign in to your GitHub account in Visual Studio Code. Select the Copilot icon at the top of Visual Studio Code to access the GitHub Copilot pane. For more information about setting up GitHub Copilot, see Set up GitHub Copilot in VS Code.
Then, use the following steps to install the extension in Visual Studio Code:
- In Visual Studio Code, open the Extensions view from the Activity Bar.
- Search for GitHub Copilot App Modernization in the marketplace.
- Select the GitHub Copilot App Modernization extension pack.
- On the extension page, select Install.
- Restart Visual Studio Code.
After installation completes, you should see a notification in the corner of Visual Studio Code confirming success.
For more information, see Install a VS Code extension.
Select a Java project to upgrade
For the purposes of this tutorial, choose one of the following sample repositories:
- Maven: uportal-messaging
- Gradle: docraptor-java
Launch GitHub Copilot Agent Mode and start the upgrade
Use the following steps to launch GitHub Copilot Agent Mode and start the upgrade process:
Open the selected Java project in Visual Studio Code.
Open the GitHub Copilot Chat panel.
Switch to Agent Mode.
Enter a prompt such as Upgrade project to Java 21 using Java upgrade tools or Upgrade project to Java 21 and Spring Boot 3.2 using Java upgrade tools to include framework information.
Note
If you need to upgrade a framework or third-party dependency only, see Upgrade a framework or third-party dependency by using GitHub Copilot App Modernization – upgrade for Java.
When prompted, select Continue to generate an upgrade plan.
Review and edit the upgrade plan
App Modernization - upgrade for Java analyzes the Java project in the current workspace, including its JDK, build tools, and dependencies. The tool generates a plan.md file that outlines the following planned changes:
- Source and target JDK versions.
- Framework and library upgrade paths.
Review the plan and make changes if needed, then select Continue to proceed. For information about further customization, such as adding more build tool parameters, see Customize the upgrade plan.
Tip
Ensure that the plan matches your desired upgrade targets - for example, Java 8 to Java 21, Spring Boot 2.7 to 3.2.
Apply code changes and fix build issues
GitHub Copilot then proceeds with the code transformation phase of the project. It uses an open-source tool called OpenRewrite to implement some code changes based on specific recipes. Then, AI addresses the remaining issues through a dynamic build/fix loop. You can monitor progress in the editor area of Visual Studio Code by checking the progress.md markdown file at any time.
At various stages of the process, GitHub Copilot prompts you to continue.
For the Confirm the OpenRewrite transformation step, select Continue to upgrade Java code using OpenRewrite. This step might take a few minutes.
For the Approve the dynamic build/fix loop step, select Continue to build the project and fix errors.
Copilot iterates and continues to fix errors until there are no more issues. Progress is shown in a progress.md file. The loop continues until the project builds successfully.
Check for vulnerabilities and code behavior changes
Under certain circumstances, the upgrade might cause code behavior changes or introduce libraries with Common Vulnerabilities and Exposures (CVE) issues. The tool performs an extra check for these issues.
When GitHub Copilot prompts Run Validate if any modified dependencies have known CVEs, select Continue.
If CVEs are found, GitHub Copilot Agent Mode attempts to fix them. Review the changes in VS Code and decide whether to keep them.
After the CVE check, when prompted to Run Validate code behavior consistency, select Continue.
If issues are found, GitHub Copilot Agent Mode tries to resolve them. Decide whether to keep or discard the changes.
After the checks complete, GitHub Copilot rebuilds the project and reruns the previous checks.
If minor issues remain that don't require immediate fixes, the upgrade is complete. Otherwise, GitHub Copilot goes back to address them.
View the summary
After the upgrade, the tool generates a summary in the summary.md file, which includes the following information:
- Project information.
- Lines of code changed.
- Updated dependencies.
- Summarized code changes.
- Fixed CVE security and code inconsistency issues, if any.
- Unaddressed minor CVE issues.
Next step
Quickstart: generate unit tests with GitHub Copilot App Modernization - upgrade for Java