From db62f83bacd1d5086020fc1f5e7d299716211f9c Mon Sep 17 00:00:00 2001 From: "James Z.M. Gao" Date: Tue, 5 Apr 2022 13:31:05 +0800 Subject: [PATCH] [MSHADE-124] keep original basedir after set d-r-p location to build dir From maven 3.2.5, the pom and basedir are seperated (https://github.com/apache/maven/commit/c15226f13f6d071d1e926880139d350cc4546b6f), and add new api `MavenProject::setPomFile()` to only upodate pom location. In this pr, the minimal maven version is bumped to 3.2.5, then use `setPomFile` to only update pom file location, leaving `${basedir}` unchanged. --- pom.xml | 2 +- src/it/projects/dep-reduced-pom/pom.xml | 22 +++++++++++++++++++ .../maven/plugins/shade/mojo/ShadeMojo.java | 6 ++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index dbd5fdd0..937c3f9c 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ - 3.1.1 + 3.2.5 8 0.3.5 ${project.version} diff --git a/src/it/projects/dep-reduced-pom/pom.xml b/src/it/projects/dep-reduced-pom/pom.xml index 44b5ad9d..bbe2aa0f 100644 --- a/src/it/projects/dep-reduced-pom/pom.xml +++ b/src/it/projects/dep-reduced-pom/pom.xml @@ -73,6 +73,28 @@ under the License. + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0 + + + enforce-basedir-is-not-changed + + enforce + + package + + + + basedir + + + + + + + diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index d717253f..ef1f4c60 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -267,9 +267,7 @@ public class ShadeMojo private boolean createDependencyReducedPom; /** - * Where to put the dependency reduced pom. Note: setting a value for this parameter with a directory other than - * ${basedir} will change the value of ${basedir} for all executions that come after the shade execution. This is - * often not what you want. This is considered an open issue with this plugin. + * Where to put the dependency reduced pom. * * @since 1.7 */ @@ -1220,7 +1218,7 @@ private void rewriteDependencyReducedPomIfWeHaveReduction( List depe modified = updateExcludesInDeps( result.getProject(), dependencies, transitiveDeps ); } - project.setFile( dependencyReducedPomLocation ); + project.setPomFile( dependencyReducedPomLocation ); } }