Make the single goal m2e-friendly - #1345
Conversation
|
I think I saw several attempts to introduce |
There was a problem hiding this comment.
Pull request overview
This PR improves Eclipse m2e compatibility for the assembly:single goal by (1) integrating BuildContext refresh behavior so generated archives are visible to workspace builds, and (2) embedding m2e lifecycle mapping metadata that ignores single by default during Eclipse workspace builds.
Changes:
- Inject
org.codehaus.plexus.build.BuildContextintoDefaultAssemblyArchiverand refresh the generated archive after creation. - Add embedded m2e lifecycle mapping metadata to ignore the
singlegoal by default. - Extend
DefaultAssemblyArchiverTestto verifyBuildContext.refresh(File)is called for the created archive, and add the required dependency.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiver.java | Adds BuildContext injection and refreshes the created archive file after createArchive(). |
| src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java | Mocks BuildContext, wires it into the subject, and verifies the refresh call for the output archive. |
| src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml | Embeds an m2e lifecycle mapping that ignores the single goal by default in Eclipse builds. |
| pom.xml | Adds the plexus-build-api dependency needed for BuildContext. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agree I don't like to native files like |
| <dependency> | ||
| <groupId>org.codehaus.plexus</groupId> | ||
| <artifactId>plexus-build-api</artifactId> | ||
| <version>1.2.0</version> | ||
| </dependency> |
There was a problem hiding this comment.
Please also consult:
|
I have removed the m2e metadata. But I am not sure what you suggest with the |
I'm not sure if it is still true:
|
The 0.0.7 version of the Sonatype artifact is supported and its latest version is 0.0.7. The Plexus artifact handles it as well, as far as I understand, with delegation via the Plexus class: |
so we need info in plexus-build-api README ... also issue 944 for m2e is still open |
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
mvn -Prun-its verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
Summary
org.codehaus.plexus.build.BuildContextinto the assembly archiver and refresh the completed archive.Fixes #1150
Why
When an m2e lifecycle mapping explicitly enables
assembly:single, the plugin can create or replace an archive without notifying the Eclipse workspace. CallingBuildContext.refresh(File)after archive creation makes the generated output visible to BuildContext-aware consumers.This PR deliberately does not embed IDE-specific lifecycle-mapping metadata. Whether m2e executes or ignores the goal remains a project, parent-POM, or m2e policy decision.
The Codehaus
plexus-build-apiimplementation is Sisu-indexed and retains its legacy API bridge, so the same constructor injection also works in ordinary Maven CLI builds.Validation
mvn -Prun-its clean verify— 268 unit tests and all 150 integration tests passed.mvn -Denforcer.skip=true -Prun-its clean verify— 268 unit tests and all 150 integration tests passed. The enforcer skip is required because the current development parent requires Maven 3.9 to build.DefaultAssemblyArchiverTestand packaging passed. The full run passed all 268 unit tests and 144 of 150 integration tests; the remaining six existing fixtures fail during Maven 4 model construction withThe parents form a cycle, before this plugin executes.mvn clean -Dtest=DefaultAssemblyArchiverTest packagepasses all 8 focused tests, Checkstyle, Spotless, RAT, and packaging; the resulting plugin JAR contains noMETA-INF/m2e/lifecycle-mapping-metadata.xml.