-
Notifications
You must be signed in to change notification settings - Fork 35
Add a sample to showcase migrating a legacy Java EE Ant project to a Jakarta EE 10 Maven project #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jianguo Ma <[email protected]>
Signed-off-by: Jianguo Ma <[email protected]>
Signed-off-by: Jianguo Ma <[email protected]>
Signed-off-by: Jianguo Ma <[email protected]>
Signed-off-by: Jianguo Ma <[email protected]>
Signed-off-by: Jianguo Ma <[email protected]>
…ption for existing sample
…nstructions and setup guidance
@galiacheng and @majguo , I'm very keen to review this. Please share the link to where I can get the private build to exercise it. Thanks, Ed |
d5c0c7b
to
76ec2a1
Compare
1. Open **Source Control** view in VSCode, and select **Discard All Changes** to discard all changes made by the assessment tool. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we discarding all changes? When I did this, it discarded the ant to maven migration. I don't think that's what you wanted me to do, right? Is there a commit step missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will proceed as if I was supposed to commit the changes from the ant to maven migration before proceeding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should discuss with AppCat team to revert to the previous state. The expected behavior for an assessment process is that it's purely functional without side effect.
It's not a problem before because we didn't work on Eclipse / Ant related projects at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my inline comments and also these notes.
Here are my consolidated notes from running through the student-web-app/README
twice.
First, and most easily to apply, consider merging my changes in galiacheng#3 . These notes apply directly to this PR.
Next, here are some notes from the experience. These notes apply to the product itself.
First run through
Convert Ant project to Maven project
Complete output log at this comment.
VSCode wrote:
Retrieves the complete content of a specific knowledge base article
using its ID. Use this tool when you have a document ID and need to
access its full content for detailed information about Java
modernization techniques.
This says to me the tool will go out to the Internet to fetch the KB. But it's not doing that, really? Isn't the KB for this workshop already local?
VSCode wrote:
I noticed a .mvn directory, which suggests there might already be Maven configuration in the project. Let me check if there's a pom.xml file:
Searched for files matching **/pom.xml, no matches
Let's check the .mvn directory to see what's there:
Read .mvn
Read wrapper
The .mvn
directory should be removed with git rm
right? It should not exist before the program is migrated to maven, right?
VSCode wrote:
Now, let's move the Java source files:
robocopy /E src src\main\java
It looks like the robocopy command had some issues. Let me try a different approach to move the files with PowerShell:
Yes, it did some horrible nested new dir thing:
See the video migration-plan.md - student-web-app - Visual Studio Code 2025-08-07 18-35-17.
I wonder if this was because I invoked code .
from a command prompt rather than from a PowerShell prompt? This did not happen when I made a second attempt, launching code .
from PowerShell.
VSCode wrote:
Now let's run the Maven build to see if our migration was successful:
Java App Modernization MCP Server (MCP Server)
We have duplicate class issues because we have both the old source
files in src and the new ones in java. Let's fix this by removing
the original source files and only keeping the Maven-style directory
structure:
Copy-Item -Recurse src src.bak
As a developer, I could see this would be a problem before the build started. Can't we make it so it moves things aside at the initial copy time?
Also, I doubt this command will do what it wants, because the initial, pre-mvn, code is in src\ca
. That will get copied also.
In my second attempt, I directed it to use the PowerShell command for moving files, rather than copying them.
VSCode wrote:
Remove-Item -Recurse -Force src\ca
Ok, so it got that, but it would be better to move than copy and then remove.
VSCode wrote:
Now let's try the build again:
It failed:
Build errors found:
duplicate class: ca.on.gov.edu.coreft.AddStudentServlet
[about 20 of these]
duplicate class: ca.on.gov.edu.coreft.IndexServlet
[about 10 of these]
duplicate class: ca.on.gov.edu.coreft.StudentProfile
[about 15 of these]
duplicate class: ca.on.gov.edu.coreft.StudentProfileListServlet
[about 10 of these]
duplicate class: ca.on.gov.edu.coreft.controller.AddStudentController
[about 20 of these]
duplicate class: ca.on.gov.edu.coreft.controller.StudentController
[about 20 of these]
duplicate class: ca.on.gov.edu.coreft.filter.CommonHttpServletFilter
[about 10 of these]
duplicate class: ca.on.gov.edu.coreft.service.StudentService
[about 20 of these]
duplicate class: ca.on.gov.edu.coreft.util.MyBatisUtil
[about 10 of these]
VSCode wrote:
I can see the issue. The paths have a series of nested main\java directories. Let's look at one of the actual Java class files to understand where the duplicates are coming from:
Yes, this was from the failed robocopy
.
Let's fix this directory structure issue. It appears we have nested main\java directories. Let's clean up the project structure by removing the current structure and recreating it properly:
I'll try to reference this by line number in the output log. This is line 20 of https://github.com/devdiv-microsoft/vscode-java-upgrade/issues/834#issuecomment-3166143239 . It was a mess but eventually, and after much work, it succeeded.
The LLM proceeded to try to copy the files from the .bak
to freshly created directories.
It doesn't put checkmarks in migration-plan.md
as we went along. Is it supposed to do that? It made spaces for checkmarks but did not do them.
Assess and detect the legacy Java EE and Spring Framework project
VSCode wrote:
Now let's run the assessment with the configured settings:
Running
appmod-run-assessment
-- Java App Modernization MCP Server (MCP Server)
It would be very nice for the user to be able to see that progress is
being made. Otherwise, the user might conclude something has happened
and progress has halted.
I realize this is a limitation of the VSCode UI, but end users may not realize that.
Indeed, I stepped away for 15 minutes and it's still in that state. When I returned, it had indeed finished.
Second run through
Convert Ant project to Maven project
Complete output log at 20250807-02-chat-log.md.
For this run through, I chose to take a more hands-on approach to interacting with the migration. I'd rather not have to do this. Perhaps the interactions I made can server as advice to improve the experience.
VS Code wrote:
Step 3: Move Java source files to Maven structure
Let's move the Java files:
edburns: I am in PowerShell. Can you use a PowerShell terminal and PowerShell commands?
GitHub Copilot: You're right, let's use PowerShell commands instead. I'll continue with the migration process using PowerShell syntax.
Then it did this. Perhaps we can detect what kind of shell the user wants and use those kind of commands? It might be nice to even detect if the user is on a mac and therefore uses zsh.
VS Code wrote:
Step 3: Move Java source files to Maven structure
edburns: Well, your migration_plan.md
says Move but your PowerShell command is copy. Don't you want to move them, not copy them?
GitHub Copilot: You're absolutely right! I should be moving the files rather than copying them. Let me correct that approach.
The migration moved more smoothly than the previous attempt.
Migrate Spring and Jakarta EE
Complete output log at 20250807-03-chat-log.md.
VS Code wrote:
GitHub Copilot: I'll help you upgrade the Spring Framework in this project to the latest stable version using the Java upgrade tools. Let me analyze the project first and then create an upgrade plan. Now I'll check some of the Java files to understand how Spring is being used in the project: Now I'll generate an upgrade plan for the Spring Framework using the Java upgrade tools: I need to identify an available JDK installation before proceeding:
edburns: I want you to use PowerShell. Use Get-Command java and similar.
GitHub Copilot: I'll use PowerShell to find the Java installation paths on your system. Now let me check what JDK versions are available: Let's look for additional Java installations: Let's check for Java 11 specifically: Let me try the JAVA_HOME environment variable: Since we only have JDK 21 available but the project is configured to use Java 11, we have two options:
- Update the project to use Java 21
- Install Java 11
This is important. It did not know that a Java 21 runtime can run Java 11 code just fine. I wasted a lot of interactions and mess fighting with it about Java runtimes. See lines 8 - 38 of the chat log.
From there it was smooth sailing.
…s-to-readme Proposed edits to README
Purpose
This pull request introduces a sample to showcase migrating a legacy Java EE Ant project to a Jakarta EE 10 Maven project.
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
How to Test
What to Check
Verify that the following are valid
Other Information