The GitHub Copilot App Modernization is an AI-powered solution designed to streamline the modernization of legacy Java applications. This tool is available as a Visual Studio Code extension and leverages GitHub Copilot to perform the following tasks:
- Application assessment and planning: Analyzes code, configuration, and dependencies. Helps you visualize every task in the modernization process, from assessment to deployment.
- Code transformations: Suggests and applies code remediation for upgrade and migration scenarios.
- Build, patching, and tests: Verifies that the project builds successfully after remediation, and applies fixes when needed. Performs Common Vulnerabilities and Exposures (CVE) checks to reduce exposure to security vulnerabilities. Migrates existing and generates new unit tests to validate modernization outcomes and improve test coverage.
- Containerization and deployment: Generates Dockerfiles for app containerization and other artifacts to automate deployment to Azure.
Prerequisites
To get started, ensure the following are installed:
- Visual Studio Code - version 1.101 or later
- GitHub Copilot account - Pro, Pro+, Business, or Enterprise plan is required
- GitHub Copilot chat extension for Visual Studio Code
- GitHub Copilot app modernization extension for Visual Studio Code
- Source and Target JDKs (Java Development Kit) - JDK 8 and JDK 21
- Maven (used in this demo) or Gradle to build Java project
- Node.js and npm (Node Package Manager) (required for building frontend app)
Project Setup
After installing all prerequisites, clone the following repository:
git clone https://github.com/yortch/spring-petclinic-angularjs
Open the project in Visual Studio Code and confirm that you can build and run the application using the instructions from the README file:
./mvnw clean install
cd spring-petclinic-server
../mvnw spring-boot:run
Navigate to the application and verify the Pet Clinic loads at: http://localhost:8080/
GitHub Copilot App Modernization extension tools
The extension includes several built-in tools to assist with upgrading Java projects. You can list these tools by asking GitHub Copilot in VS Code (using agent mode with Claude Sonnet 4): "Which tools are available in the GitHub Copilot App Modernization extension?". You'll see output similar to the following:
- Java Project Upgrade and Modernization Tools
- Core Upgrade Management
- generate_upgrade_plan_for_java_project - Creates comprehensive upgrade plans for Java projects with session management
- setup_development_environment_for_upgrade - Sets up required development environment including build tools and JDKs
- upgrade_java_project_using_openrewrite - Applies OpenRewrite recipes for automated code upgrades
- summarize_upgrade - Generates summaries of completed upgrade processes
- Build and Testing
- build_java_project - Builds Java projects using Maven/Gradle with smart detection
- run_tests_for_java - Executes test cases and reports results
- generate_tests_for_java - Automatically generates test cases for Java classes
- Environment Management
- install_jdk - Downloads and installs specific JDK versions
- install_maven - Downloads and installs Maven build tool
- list_jdks - Lists available JDK installations on the system
- list_mavens - Lists available Maven installations
- Security and Validation
- validate_cves_for_java - Checks Java dependencies for security vulnerabilities
- validate_behavior_changes_for_java - Validates that code changes maintain functionality
- appmod-validate-cve - Validates Maven dependencies for known CVEs
- Assessment and Migration Tools
- migration_assessmentReport - Opens assessment report webview for migration analysis
- uploadAssessSummaryReport - Uploads assessment summaries to GitHub issues
- Configuration and Utility Tools
- appmod-get-vscode-config - Retrieves extension configuration settings
- appmod-preview-markdown - Previews Markdown files (upgrade plans, reports)
- Core Upgrade Management
- Key Capabilities
- Supported Upgrade Targets
- Spring Boot: 2.7.x → 3.2.x, 3.3.x, 3.4.x, 3.5.x
- Jakarta EE: → 10.0.x
- Spring Framework: → 6.1.x, 6.2.x
- Java Versions: 8, 11, 17, 21
- Workflow Features
- Intelligent Planning: Analyzes projects and creates detailed upgrade roadmaps
- Automated Dependency Management: Updates and validates dependency versions
- Security Analysis: CVE scanning and vulnerability assessment
- Quality Assurance: Test generation and behavior validation
- Environment Setup: Automatic detection and installation of required tools
- Comprehensive Reporting: Detailed summaries and Azure readiness analysis
- Supported Upgrade Targets
The generate_tests_for_java tool can be used independently to increase test coverage before upgrading, helping validate that there no breaking changes are introduced.
The upgrade_java_project_using_openrewrite tool uses OpenRewrite, an open-source project with Java upgrade-specific recipes. At the time of writing, version 1.5.2 of the upgrade plugin is used.
Java Project Upgrade
To begin the upgrade, use the generate_upgrade_plan_for_java_project tool. Ensure all file changes are committed or discarded beforehand to avoid warnings.
Using Agent mode with Claude Sonnet 4 as the model in GitHub Copilot, provide a prompt similar to the following, replacing the JDK paths from your local setup:
#generate_upgrade_plan_for_java_project for spring-petclinic-server project into Java 21 and
latest SpringBoot 3.5 available using jdk 8 location: C:\Users\jbalderas\apps\jdk8u442-b06
and jdk21 location: C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot
After a few minutes, a preview of the upgrade plan will be displayed. Review and update the plan as needed. If it meets your expectations, click Continue:
Generated upgrade planAs the upgrade proceeds, you'll see each step completed with logs available from build output, unit test results, as well as any failures. The extension will iterate through build and test errors, resolving them incrementally. Occasionally, you may need to click Continue if the tool loops through a task multiple times.
Once complete, a summary screen will show all changes and the upgrade status:
Upgrade Java project completionDuring our upgrade, we noticed that the Maven wrapper (mvnw) was not automatically updated. This caused build failures due to version incompatibility (this was undetected during the upgrade because maven was used directly). To resolve this, ask GitHub Copilot:
Upgrade maven wrapper to at least version 3.6.3
This updates the distributionUrl in the maven-wrapper.properties file. Click Keep to accept the changes.
There was one additional error when attempting to run the application. I asked GitHub Copilot to fix using this prompt:
Why is the ../mvw spring-boot:run failing with "could not find or load main class" error after upgrade?
GitHub Copilot found that the error was caused by the fork parameter no longer valid in the spring-boot-maven-plugin configuration in the pom.xml file.
After GitHub Copilot fixed that, the run command was working again:
cd spring-petclinic-server
../mvnw spring-boot:run
Visit http://localhost:8080 to confirm the Pet Clinic loads successfully.
Spring PetClinic welcome screenAll changes should be committed to a branch named appmod/java-upgrade-<unique id>. If there are any remaining changes, commit and push them, then create a pull request. For reference, the upgraded version from this exercise is available in this branch: appmod/java-upgrade-20250929193125
Here's an example of a draft pull request showing 30 changed files across 12 commits, completed in just minutes:
Pull request for upgradeWe hope this walkthrough demonstrates how the GitHub Copilot App Modernization extension can save time and eliminate the tedious work of upgrading legacy Java code. Give it a try and share your feedback below!