Skip to content

Make the single goal m2e-friendly - #1345

Open
wilx wants to merge 1 commit into
apache:masterfrom
wilx:issue-1150
Open

Make the single goal m2e-friendly#1345
wilx wants to merge 1 commit into
apache:masterfrom
wilx:issue-1150

Conversation

@wilx

@wilx wilx commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (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

  • Inject org.codehaus.plexus.build.BuildContext into the assembly archiver and refresh the completed archive.
  • Verify that archive creation refreshes the output path.

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. Calling BuildContext.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-api implementation is Sisu-indexed and retains its legacy API bridge, so the same constructor injection also works in ordinary Maven CLI builds.

Validation

  • Maven 3.9.16 / JDK 21: mvn -Prun-its clean verify — 268 unit tests and all 150 integration tests passed.
  • Maven 3.6.3 / JDK 8: 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.
  • Maven 4.0.0-rc-5 / JDK 21: the focused DefaultAssemblyArchiverTest and 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 with The parents form a cycle, before this plugin executes.
  • After removing the lifecycle metadata, mvn clean -Dtest=DefaultAssemblyArchiverTest package passes all 8 focused tests, Checkstyle, Spotless, RAT, and packaging; the resulting plugin JAR contains no META-INF/m2e/lifecycle-mapping-metadata.xml.

@wilx
wilx marked this pull request as ready for review July 30, 2026 14:00
@pzygielo

Copy link
Copy Markdown
Contributor

I think I saw several attempts to introduce META-INF/m2e/lifecycle-mapping-metadata.xml into maven-X-plugin to be rejected... Would be surprised for this one to go through.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.BuildContext into DefaultAssemblyArchiver and refresh the generated archive after creation.
  • Add embedded m2e lifecycle mapping metadata to ignore the single goal by default.
  • Extend DefaultAssemblyArchiverTest to verify BuildContext.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.

@slawekjaranowski

Copy link
Copy Markdown
Member

I think I saw several attempts to introduce META-INF/m2e/lifecycle-mapping-metadata.xml into maven-X-plugin to be rejected... Would be surprised for this one to go through.

Agree I don't like to native files like META-INF/m2e/lifecycle-mapping-metadata.xml in plugins ... if we go in this way we can end with many configurations for all IDE ...

Comment thread pom.xml
Comment on lines +174 to +178
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>1.2.0</version>
</dependency>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@wilx

wilx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

I have removed the m2e metadata. But I am not sure what you suggest with the plexus-build-api related comment.

@slawekjaranowski

Copy link
Copy Markdown
Member

I have removed the m2e metadata. But I am not sure what you suggest with the plexus-build-api related comment.

I'm not sure if it is still true:
https://github.com/codehaus-plexus/plexus-build-api#m2eclipse

Currently only versions up to 0.0.7 (with old Maven coordinates org.sonatype.plexus:plexus-build-api) are supported, this limitation is tracked in eclipse-m2e/m2e-core#944.

@wilx

wilx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

I have removed the m2e metadata. But I am not sure what you suggest with the plexus-build-api related comment.

I'm not sure if it is still true: https://github.com/codehaus-plexus/plexus-build-api#m2eclipse

Currently only versions up to 0.0.7 (with old Maven coordinates org.sonatype.plexus:plexus-build-api) are supported, this limitation is tracked in eclipse-m2e/m2e-core#944.

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:

https://github.com/codehaus-plexus/plexus-build-api/blob/4576fedb9b7cc3598d87ec42e9fe11acb2ef1bc1/src/main/java/org/codehaus/plexus/build/DefaultBuildContext.java#L72-L80

@slawekjaranowski

Copy link
Copy Markdown
Member

I have removed the m2e metadata. But I am not sure what you suggest with the plexus-build-api related comment.

I'm not sure if it is still true: https://github.com/codehaus-plexus/plexus-build-api#m2eclipse

Currently only versions up to 0.0.7 (with old Maven coordinates org.sonatype.plexus:plexus-build-api) are supported, this limitation is tracked in eclipse-m2e/m2e-core#944.

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:

https://github.com/codehaus-plexus/plexus-build-api/blob/4576fedb9b7cc3598d87ec42e9fe11acb2ef1bc1/src/main/java/org/codehaus/plexus/build/DefaultBuildContext.java#L72-L80

so we need info in plexus-build-api README ... also issue 944 for m2e is still open

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.

[MASSEMBLY-942] Make "single" goal m2e-friendly by using BuildContext

5 participants