Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9.x][MNG-7795] IllegalArgumentException: 'other' has different root durin… #1128

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.inject.Singleton;

import java.io.File;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -222,16 +223,14 @@ private String pluginDeclaration(MavenSession mavenSession, MojoDescriptor mojoD
if (location.contains("://")) {
stringBuilder.append(" (").append(location).append(")");
} else {
File rootBasedir = mavenSession.getTopLevelProject().getBasedir();
File locationFile = new File(location);
if (location.startsWith(rootBasedir.getPath())) {
stringBuilder
.append(" (")
.append(rootBasedir.toPath().relativize(locationFile.toPath()))
.append(")");
} else {
stringBuilder.append(" (").append(location).append(")");
Path topLevelBasedir =
mavenSession.getTopLevelProject().getBasedir().toPath();
Path locationPath =
new File(location).toPath().toAbsolutePath().normalize();
if (locationPath.startsWith(topLevelBasedir)) {
locationPath = topLevelBasedir.relativize(locationPath);
}
stringBuilder.append(" (").append(locationPath).append(")");
}
}
stringBuilder.append(" @ line ").append(inputLocation.getLineNumber());
Expand All @@ -246,8 +245,13 @@ private String pluginOccurrence(MavenSession mavenSession) {
String result = prj.getGroupId() + ":" + prj.getArtifactId() + ":" + prj.getVersion();
File currentPom = prj.getFile();
if (currentPom != null) {
File rootBasedir = mavenSession.getTopLevelProject().getBasedir();
result += " (" + rootBasedir.toPath().relativize(currentPom.toPath()) + ")";
Path topLevelBasedir =
mavenSession.getTopLevelProject().getBasedir().toPath();
Path current = currentPom.toPath().toAbsolutePath().normalize();
if (current.startsWith(topLevelBasedir)) {
current = topLevelBasedir.relativize(current);
}
result += " (" + current + ")";
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.cli.event;

import java.io.File;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -296,8 +297,12 @@ public void projectStarted(ExecutionEvent event) {
File currentPom = project.getFile();
if (currentPom != null) {
MavenSession session = event.getSession();
File rootBasedir = session.getTopLevelProject().getBasedir();
logger.info(" from " + rootBasedir.toPath().relativize(currentPom.toPath()));
Path topLevelBasedir = session.getTopLevelProject().getBasedir().toPath();
Path current = currentPom.toPath().toAbsolutePath().normalize();
if (current.startsWith(topLevelBasedir)) {
current = topLevelBasedir.relativize(current);
}
logger.info(" from " + current);
}

// ----------[ packaging ]----------
Expand Down