diff --git a/src/it/projects/MSHADE-419_attachedDepPom/pom.xml b/src/it/projects/MSHADE-419_attachedDepPom/pom.xml
new file mode 100644
index 00000000..959a232d
--- /dev/null
+++ b/src/it/projects/MSHADE-419_attachedDepPom/pom.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.shade
+ mshade-419
+ 1.0
+ jar
+
+ MSHADE-419
+
+ Test that project.getFile() still points to the original pom.xml
+ when shadedArtifactAttached=true, preventing the dependency-reduced
+ POM from being used for install/deploy.
+
+
+
+
+ org.apache.maven.its.shade.fac
+ a
+ 0.1
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ @project.version@
+
+
+ shade
+ package
+
+ shade
+
+
+ true
+ shaded
+ ${project.build.directory}/dependency-reduced-pom.xml
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-help-plugin
+ 3.3.0
+
+
+ check-project-file
+ package
+
+ evaluate
+
+
+ project.file
+ true
+
+
+
+
+
+
+
diff --git a/src/it/projects/MSHADE-419_attachedDepPom/verify.groovy b/src/it/projects/MSHADE-419_attachedDepPom/verify.groovy
new file mode 100644
index 00000000..aee5a749
--- /dev/null
+++ b/src/it/projects/MSHADE-419_attachedDepPom/verify.groovy
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// Verify the dependency-reduced POM was created in the expected location
+File drpFile = new File(basedir, "target/dependency-reduced-pom.xml")
+assert drpFile.isFile() : "DRP should exist at " + drpFile
+
+// Verify the original (non-shaded) artifact exists
+File originalJar = new File(basedir, "target/mshade-419-1.0.jar")
+assert originalJar.isFile() : "Original artifact should exist at " + originalJar
+
+// Verify the shaded (attached) artifact exists with the classifier
+File shadedJar = new File(basedir, "target/mshade-419-1.0-shaded.jar")
+assert shadedJar.isFile() : "Shaded artifact should exist at " + shadedJar
+
+// Verify that project.getFile() still points to the original pom.xml after shading,
+// NOT to the dependency-reduced-pom.xml. This is critical because when
+// shadedArtifactAttached=true, the original artifact is the main artifact and
+// its POM comes from project.getFile(). If project.getFile() points to the DRP,
+// the deployed POM will lose all compile dependencies.
+File buildLog = new File(basedir, "../build.log")
+if (!buildLog.isFile()) {
+ buildLog = new File(basedir, "build.log")
+}
+assert buildLog.isFile() : "build.log should exist"
+
+def lines = buildLog.readLines()
+def projectFileLine = lines.find { it =~ /^\// && it.endsWith("/pom.xml") }
+assert projectFileLine != null : "project.file value not found in build log (expected a path ending with /pom.xml)"
+assert projectFileLine.endsWith("/pom.xml") : "project.file should be pom.xml, but was: " + projectFileLine
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 09e3956f..644ca93c 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
@@ -544,6 +544,7 @@ public void execute() throws MojoExecutionException {
List resourceTransformers = getResourceTransformers();
if (createDependencyReducedPom) {
+ File originalProjectFile = project.getFile();
createDependencyReducedPom(artifactIds);
if (useDependencyReducedPomInJar) {
@@ -551,6 +552,7 @@ public void execute() throws MojoExecutionException {
resourceTransformers = new ArrayList<>(resourceTransformers);
resourceTransformers.addAll(createPomReplaceTransformers(project, dependencyReducedPomLocation));
}
+ project.setFile(originalProjectFile);
}
ShadeRequest shadeRequest =