mirror of https://github.com/apache/maven.git
[MNG-7795] IllegalArgumentException: 'other' has different root during plugin validation (#1128)
Checks the paths before relativizing them. Normalize and relative before adding to result Rename local vars Apply to ExecutionEventLogger --- https://issues.apache.org/jira/browse/MNG-7795
This commit is contained in:
parent
8cc6b2710d
commit
23a3a9127d
|
@ -22,6 +22,7 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -261,16 +262,14 @@ public final class DefaultPluginValidationManager extends AbstractEventSpy imple
|
|||
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());
|
||||
|
@ -285,8 +284,13 @@ public final class DefaultPluginValidationManager extends AbstractEventSpy imple
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -296,8 +297,12 @@ public class ExecutionEventLogger extends AbstractExecutionListener {
|
|||
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 ]----------
|
||||
|
|
Loading…
Reference in New Issue