[MSHADE-154] - Add ability to shade an attached primary artifact - #833
Open
wilx wants to merge 4 commits into
Open
[MSHADE-154] - Add ability to shade an attached primary artifact#833wilx wants to merge 4 commits into
wilx wants to merge 4 commits into
Conversation
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
marked this pull request as ready for review
July 31, 2026 16:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following this checklist to help us incorporate your
contribution quickly and easily:
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.
mvn clean verifypasses.mvn -Prun-its clean verify.Summary
Add an optional
inputClassifierparameter that lets the Shade Plugin use anartifact 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. Aplugin 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 passedmvn -Prun-its clean verify— 84 integration tests passed; 2 existingJRE-dependent tests were skipped under Java 8
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.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.