elharo commented on code in PR #843:
URL:
https://github.com/apache/maven-shade-plugin/pull/843#discussion_r3886461054
##########
src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java:
##########
@@ -1260,6 +1269,21 @@ private void
rewriteDependencyReducedPomIfWeHaveReduction(
}
}
+ /**
+ * True when the configured relativePath file is the project's parent POM.
+ */
+ private static boolean isSameFile(File configured, File actual) {
+ try {
+ return actual != null
+ && configured != null
+ && actual.isFile()
+ && configured.isFile()
+ &&
actual.getCanonicalFile().equals(configured.getCanonicalFile());
+ } catch (IOException e) {
+ return false;
Review Comment:
IIOException usually doesn't mean false. It's an exception that should be
thrown
##########
src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java:
##########
@@ -1230,8 +1230,17 @@ private void
rewriteDependencyReducedPomIfWeHaveReduction(
parentFile = parentFile.getCanonicalFile();
- String relPath =
RelativizePath.convertToRelativePath(parentFile, f);
- model.getParent().setRelativePath(relPath);
+ File actualParentFile =
+ project.getParent() != null ?
project.getParent().getFile() : null;
+ if (isSameFile(parentFile, actualParentFile)) {
+ String relPath =
RelativizePath.convertToRelativePath(parentFile, f);
+ model.getParent().setRelativePath(relPath);
+ } else {
+ // ../pom.xml is a different GAV (or missing). An empty
Review Comment:
../pom.xml has a different GAV (or does not have one).
--
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]