arturobernalg opened a new pull request, #882:
URL: https://github.com/apache/maven-shade-plugin/pull/882

   When `outputDirectory` is set to a directory other than the default build 
directory and `finalName` is left at its default value (equal to 
`project.getBuild().getFinalName()`), `ShadeMojo` replaces the project's main 
artifact in place at its original location instead of moving it to the 
configured `outputDirectory`. The pre-shade jar is correctly backed up as 
`original-<name>.jar` under `outputDirectory`, but the shaded jar itself is 
left behind in the default build directory, so the two effectively end up 
swapped relative to what the user configured.
   
   The shaded sources, test and test-sources artifacts already route through 
`shadedArtifactFile()`, which places them under `outputDirectory`. The main 
artifact's replacement path skipped that and used 
`project.getArtifact().getFile()` directly as both the backup source and the 
destination, so the destination never accounted for a custom `outputDirectory`.
   
   The fix adds a `shadedMainArtifactFile()` helper that mirrors the existing 
sources/test helpers, generalizes `replaceFile` to take a separate 
backup-source file and destination file, and updates the project artifact's 
file reference after the move so downstream plugins pick up the shaded jar at 
its new location.
   
   Added a unit test for the main-artifact file computation and the generalized 
`replaceFile` behavior, plus an integration test under 
`src/it/projects/MSHADE-354` that configures a custom `outputDirectory` with a 
default `finalName` and asserts the shaded jar lands there while the original 
is preserved alongside it. Verified the integration test fails on master 
without the fix and passes with it. Full unit test suite and `mvn -Prun-its 
verify` both pass, and checkstyle/spotless are clean.
   
   Fixes #354
   
   To make clear that you license your contribution under the [Apache License 
Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) check 
one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to