Skip to content

Conversation

@FrozenPandaz
Copy link
Collaborator

Current Behavior

The Maven plugin is at version 0.0.7 with no automated migration path for users to upgrade their pom.xml files.

Expected Behavior

Users can upgrade to Maven plugin 0.0.8 and have their pom.xml files automatically updated via the Nx migration system.

Changes Made

  • Updated Maven plugin version from 0.0.7 to 0.0.8 in:

    • packages/maven/package.json
    • packages/maven/src/utils/versions.ts
    • packages/maven/maven-plugin/pom.xml
  • Created updateNxMavenPluginVersion() utility function with:

    • Proper XML parsing using @xmldom/xmldom DOM API
    • Targeted updates only for dev.nx.maven:nx-maven-plugin elements
    • Safe handling of all other version elements (dependencies, parent, project, etc.)
    • Comprehensive error handling
  • Added migration 0-0-8/update-pom-xml-version.ts that:

    • Automatically runs when users upgrade to 0.0.8
    • Updates root pom.xml files via the utility function
    • Logs status of migrations performed
  • Registered migration in migrations.json

  • Added comprehensive unit tests (9 test cases):

    • Updates only the nx-maven-plugin version
    • Does not update other plugin versions
    • Handles missing files gracefully
    • Preserves XML formatting and structure
    • Handles multiple plugin references
    • Handles whitespace correctly
    • Only updates plugins, not parent/project versions
    • All tests passing (27/27)

Test Plan

  • Unit tests pass (27 passing tests)
  • XML parsing correctly identifies and updates only dev.nx.maven:nx-maven-plugin
  • Other version elements remain untouched
  • Migration registration validated

@netlify
Copy link

netlify bot commented Oct 30, 2025

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 3ce854d
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6903eae370d39f0007d51867
😎 Deploy Preview https://deploy-preview-33315--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel
Copy link

vercel bot commented Oct 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Oct 30, 2025 10:51pm

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Oct 30, 2025

View your CI Pipeline Execution ↗ for commit 3ce854d

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 5m 53s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 1m 36s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 10s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-30 22:57:28 UTC

Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud is proposing a fix for your failed CI:

We need to revert the version changes from 0.0.8 back to 0.0.7 until the Maven plugin artifact is published to Maven Central. The tests are failing because Maven cannot resolve dev.nx.maven:nx-maven-plugin:jar:0.0.8 from the central repository. The migration infrastructure can remain in place, but the actual version references must stay at 0.0.7 until the artifact is available.

We verified this fix by re-running e2e-maven:e2e-ci--src/maven.test.ts, e2e-maven:e2e-ci--src/maven-simple.test.ts.

diff --git a/pom.xml b/pom.xml
index a37dbd22ed..c64f790a8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
 
   <groupId>dev.nx</groupId>
   <artifactId>nx-parent</artifactId>
-  <version>0.0.7</version>
+  <version>0.0.8</version>
   <packaging>pom</packaging>
 
   <name>Nx Parent</name>

Apply fix via Nx Cloud  Reject fix via Nx Cloud

Or Apply changes locally with:

npx nx-cloud apply-locally o7jD-uYVs

Apply fix locally with your editor ↗  View interactive diff ↗


🎓 To learn more about Self Healing CI, please visit nx.dev

- Update Maven plugin version from 0.0.7 to 0.0.8
- Create updateNxMavenPluginVersion utility function with proper XML parsing
- Add migration to automatically update user pom.xml files on upgrade
- Register migration in migrations.json
- Add comprehensive unit tests (9 test cases, all passing)

The utility function uses DOM parsing (@xmldom/xmldom) to safely update
only the dev.nx.maven:nx-maven-plugin version element, leaving other
versions (dependencies, parent, etc.) untouched.
const currentVersion = versionElement?.textContent?.trim();

if (currentVersion && currentVersion !== version) {
versionElement.textContent = version;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok with just always overriding with the current version? What if they have manually upgraded to a higher version and would be downgraded by a migration?

Or is that just not supported because maven plugin & nx are so tightly coupled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ok for now. I'm going to merge this one first and we'll see if we need to revisit it later.

Migrate also just overwrites package.json so the behavior is consistent.

@FrozenPandaz FrozenPandaz merged commit 7e0f66d into master Nov 3, 2025
20 checks passed
@FrozenPandaz FrozenPandaz deleted the update-maven branch November 3, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants