Skip to content

Commit 92a5be3

Browse files
committed
Fix Poms having an absolute path when they should have a relative path
1 parent b5fa41a commit 92a5be3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rewrite-maven/src/main/java/org/openrewrite/maven/MavenParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ public List<Xml.Document> parseInputs(Iterable<Input> sources, @Nullable Path re
8181
Map<Xml.Document, Pom> projectPoms = new LinkedHashMap<>();
8282
Map<Path, Pom> projectPomsByPath = new HashMap<>();
8383
for (Input source : sources) {
84-
Pom pom = RawPom.parse(source.getSource(), null).toPom(source.getPath(), null);
84+
Path pomPath = (relativeTo == null) ?
85+
source.getPath() :
86+
relativeTo.relativize(source.getPath());
87+
Pom pom = RawPom.parse(source.getSource(), null)
88+
.toPom(pomPath, null);
8589
if (relativeTo != null) {
8690
if (pom.getProperties() == null || pom.getProperties().isEmpty()) {
8791
pom = pom.withProperties(new LinkedHashMap<>());
@@ -95,7 +99,7 @@ public List<Xml.Document> parseInputs(Iterable<Input> sources, @Nullable Path re
9599
.iterator().next();
96100

97101
projectPoms.put(xml, pom);
98-
projectPomsByPath.put(source.getPath(), pom);
102+
projectPomsByPath.put(pomPath, pom);
99103
}
100104

101105
List<Xml.Document> parsed = new ArrayList<>();

0 commit comments

Comments
 (0)