Skip to content

Migrate maven-war-plugin to Maven 4 native plugin API#635

Closed
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:migrate-maven-war-plugin-to-maven-4-x-native-plugi
Closed

Migrate maven-war-plugin to Maven 4 native plugin API#635
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:migrate-maven-war-plugin-to-maven-4-x-native-plugi

Conversation

@gnodet

@gnodet gnodet commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Migrate maven-war-plugin from Maven 3.x API to Maven 4.x native plugin API, following the same pattern used by maven-jar-plugin, maven-resources-plugin, and maven-compiler-plugin.

Key changes

  • pom.xml: Switched to Maven 4 API dependencies, maven-archiver 4.0.0-beta-5, maven-filtering 4.0.0-beta-1, plugin tools 4.0.0-beta-1. Removed maven-mapping 3.0.0 (replaced with local implementation). Java baseline raised to 17.
  • Mojo classes: extends AbstractMojoimplements Mojo, @Inject field injection, simplified @Mojo annotations, unified MojoException
  • DI annotations: org.apache.maven.plugins.annotations.*org.apache.maven.api.di.Inject + org.apache.maven.api.plugin.annotations.*
  • Project/Session API: MavenProjectProject, MavenSessionSession, MavenProjectHelperProjectManager
  • Artifact API: o.a.m.artifact.Artifacto.a.m.api.Artifact/DownloadedArtifact, getFile()getPath()
  • Archive/Filtering: o.a.m.archivero.a.m.shared.archiver, Resource from maven-filtering
  • Dependency resolution: project.getCompileClasspathElements()session.resolveDependencies(project, PathScope.MAIN_COMPILE)
  • Test infrastructure: All test stubs migrated from Maven 3 types to Maven 4 API types

Reference plugins

Build verification

mvn clean install -B passes with 64 unit tests, 0 failures. Integration tests (src/it/) were not modified.

Test plan

  • mvn clean install -B passes (compilation + 64 unit tests)
  • Integration tests pass via mvn verify -Prun-its (requires Maven 4 runtime)
  • Manual verification of WAR packaging with a sample project

🤖 Generated with Claude Code

Migrate all source code (src/main/java) and unit tests (src/test/java)
from Maven 3 API to Maven 4 native plugin API. Key changes:

Source code:
- Replace Maven 3 Mojo/AbstractMojo with Maven 4 @mojo annotations
- Use Maven 4 Session for dependency resolution instead of
  project.getArtifacts()
- Replace MavenProject with Maven 4 Project API
- Use Maven 4 Artifact/DownloadedArtifact instead of Maven 3 Artifact
- Replace MojoExecutionException with MojoException
- Replace Maven 3 Resource with maven-filtering Resource

Tests:
- Convert all test classes to use @MojoTest/@InjectMojo annotations
- Create MockSessionHelper utility to bridge Maven 4 session-based
  dependency resolution in tests
- Update test stubs to extend Maven 4 ProjectStub/ArtifactStub
- Fix filename mapping interpolation patterns for Maven 4 (@{ } vs @{ }@)
- Update test assertions for Maven 4 artifact extension behavior
- Mock resolveDependencies for Servlet 3.0 detection test

All 64 unit tests pass. Integration tests are not modified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet closed this Jul 24, 2026
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.

1 participant