From 20dda11950dbd898c16f4ca553a9efecfc9db4de Mon Sep 17 00:00:00 2001 From: marcel-gepardec Date: Wed, 17 Jul 2024 12:40:58 +0200 Subject: [PATCH 1/3] A property resolver has been added to the normal project version, not just the parent version. --- .../src/main/java/org/openrewrite/maven/MavenParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/MavenParser.java b/rewrite-maven/src/main/java/org/openrewrite/maven/MavenParser.java index a5562c7df97..9839dc8a82a 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/MavenParser.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/MavenParser.java @@ -152,7 +152,7 @@ public Stream parseInputs(Iterable sources, @Nullable Path re if (parent != null && resolutionResult.getPom().getGroupId().equals(resolutionResult.getPom().getValue(parent.getGroupId())) && resolutionResult.getPom().getArtifactId().equals(resolutionResult.getPom().getValue(parent.getArtifactId())) && - resolutionResult.getPom().getVersion().equals(resolutionResult.getPom().getValue(parent.getVersion()))) { + Objects.equals(resolutionResult.getPom().getValue(resolutionResult.getPom().getVersion()), resolutionResult.getPom().getValue(parent.getVersion()))) { moduleResolutionResult.unsafeSetParent(resolutionResult); modules.add(moduleResolutionResult); } From d8d526b7b0b8d46639d7f1303793a2354a2c57f0 Mon Sep 17 00:00:00 2001 From: marcel-gepardec Date: Wed, 17 Jul 2024 14:44:56 +0200 Subject: [PATCH 2/3] Added test for the property resolver of the project version --- .../openrewrite/maven/MavenParserTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java index 791f5d3208e..3e9d678cc7d 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java @@ -3157,4 +3157,48 @@ void circularMavenProperty() { ) ); } + + @Test + void multiModulePropertyVersionShouldAddModules() { + rewriteRun( + mavenProject("root", + pomXml( + """ + + example + example-root + pom + ${revision} + + + 1.0.1 + + + + example-child + + + """, + spec -> spec.afterRecipe(pomXml -> assertThat( + pomXml.getMarkers().findFirst(MavenResolutionResult.class).orElseThrow() + .getModules()).isNotEmpty()) + ), + mavenProject("multiModule-example-child", + pomXml( + """ + + + example + example-root + ${revision} + + + example-child + + """ + ) + ) + ) + ); + } } From ffd6feda9db8b73a85f732c554cd4e1a42f9b5f0 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 17 Jul 2024 17:53:37 +0200 Subject: [PATCH 3/3] Apply suggestions from code review --- .../src/test/java/org/openrewrite/maven/MavenParserTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java index 3e9d678cc7d..3a6cb276ec8 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/MavenParserTest.java @@ -3159,6 +3159,7 @@ void circularMavenProperty() { } @Test + @Issue("https://github.com/openrewrite/rewrite/issues/4319") void multiModulePropertyVersionShouldAddModules() { rewriteRun( mavenProject("root", @@ -3183,7 +3184,7 @@ void multiModulePropertyVersionShouldAddModules() { pomXml.getMarkers().findFirst(MavenResolutionResult.class).orElseThrow() .getModules()).isNotEmpty()) ), - mavenProject("multiModule-example-child", + mavenProject("example-child", pomXml( """