Skip to content

[MSHADE-154] - Add ability to shade an attached primary artifact - #833

Open
wilx wants to merge 4 commits into
apache:masterfrom
wilx:issue-516-input-classifier
Open

[MSHADE-154] - Add ability to shade an attached primary artifact#833
wilx wants to merge 4 commits into
apache:masterfrom
wilx:issue-516-input-classifier

Conversation

@wilx

@wilx wilx commented Jul 31, 2026

Copy link
Copy Markdown

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

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request has a meaningful subject line and body.
  • The pull request title uses the corresponding MSHADE issue number.
  • The pull request description explains what the pull request does, how, and why.
  • mvn clean verify passes.
  • The integration tests pass with mvn -Prun-its clean verify.

Summary

Add an optional inputClassifier parameter that lets the Shade Plugin use an
artifact attached to the current project as its primary input. When the
parameter is omitted or blank, the plugin continues to use the project's main
artifact.

Root cause

The plugin always used MavenProject#getArtifact() as the primary input. A
plugin could produce and attach a classified JAR before the shade execution,
but Shade had no way to select it. Projects that intentionally produced only
the classified artifact consequently failed because the main artifact did not
exist.

Implementation

The selected attachment is found directly in the current project's attached
artifacts. Missing and ambiguous classifier selections fail with actionable
messages. The selected artifact is then used consistently for artifact-set
selection, archive filtering, and minimization.

When the shaded artifact is not attached separately, it retains the existing
output semantics and becomes the project's main artifact. The original
classified input remains attached and is not overwritten.

The new integration test covers selection of a classified input, archive
filtering, dependency minimization, preservation of the input attachment, and
installation of the shaded JAR as the main artifact. Unit tests cover default,
successful, missing, and ambiguous selection.

Verification

  • mvn clean verify — 76 tests passed
  • mvn -Prun-its clean verify — 84 integration tests passed; 2 existing
    JRE-dependent tests were skipped under Java 8
  • The focused reproducer also passed under Maven 4.0.0-rc-5

Fixes #516.

To make clear that I license this contribution under the
Apache License Version 2.0, January 2004,
I acknowledge this using the following check-box.

wilx added 4 commits July 31, 2026 16:19
Allow an attached project artifact to serve as the primary shade input while preserving the existing output semantics. Cover selection, filtering, minimization, and installation with unit and integration tests.

Fixes apache#516.
Use the selected artifact handler when naming and attaching shaded output. Reject incompatible main-artifact replacement and cover both accepted and rejected POM-project cases.
Derive source, test, and test-source paths from the selected input artifact. Cover their creation and contents when a POM project shades an attached JAR.
Resolve source and test extensions from their own Maven artifact handlers instead of the primary shade input. Cover a ZIP primary artifact accompanied by source, test, and test-source JARs.
@wilx
wilx marked this pull request as ready for review July 31, 2026 16:27
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.

[MSHADE-154] Add ability for shade to find primary artifact from attached artifacts (similar to assembly-plugin)

1 participant