Skip to content

Commit

Permalink
Preserving parent associations in multi-module maven projects using C…
Browse files Browse the repository at this point in the history
…I-friendly versions (openrewrite#2049)
  • Loading branch information
nmck257 committed Jul 15, 2022
1 parent ffe19cc commit a725aa9
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.openrewrite.HttpSenderExecutionContextView;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.Parser;
import org.openrewrite.internal.PropertyPlaceholderHelper;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.ipc.http.HttpSender;
import org.openrewrite.maven.internal.MavenPomDownloader;
Expand Down Expand Up @@ -112,6 +113,7 @@ public List<Xml.Document> parseInputs(Iterable<Input> sources, @Nullable Path re
parsed.add(docToPom.getKey().withMarkers(docToPom.getKey().getMarkers().compute(model, (old, n) -> n)));
}

PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}", null);
for (int i = 0; i < parsed.size(); i++) {
Xml.Document maven = parsed.get(i);
MavenResolutionResult resolutionResult = maven.getMarkers().findFirst(MavenResolutionResult.class)
Expand All @@ -128,7 +130,9 @@ public List<Xml.Document> parseInputs(Iterable<Input> sources, @Nullable Path re
if (parent != null &&
parent.getGroupId().equals(resolutionResult.getPom().getGroupId()) &&
parent.getArtifactId().equals(resolutionResult.getPom().getArtifactId()) &&
parent.getVersion().equals(resolutionResult.getPom().getVersion())) {
propertyPlaceholderHelper.replacePlaceholders(
parent.getVersion(), resolutionResult.getPom().getProperties()::get)
.equals(resolutionResult.getPom().getVersion())) {
moduleResolutionResult.unsafeSetParent(resolutionResult);
modules.add(moduleResolutionResult);
}
Expand Down

0 comments on commit a725aa9

Please sign in to comment.