diff --git a/src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java b/src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java index 5672ae725f..894ce244c8 100644 --- a/src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java +++ b/src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java @@ -79,7 +79,6 @@ public String getDescription() { @Override public TreeVisitor getVisitor() { return new MavenIsoVisitor() { - final Set propertiesExplicitlyReferenced = new HashSet<>(); boolean compilerPluginConfiguredExplicitly; @Override @@ -99,7 +98,7 @@ public Xml.Document visitDocument(Xml.Document document, ExecutionContext ctx) { MavenResolutionResult mrr = getResolutionResult(); Map currentProperties = mrr.getPom().getRequested().getProperties(); for (String property : JAVA_VERSION_PROPERTIES) { - if (currentProperties.containsKey(property) || !propertiesExplicitlyReferenced.contains(property)) { + if (currentProperties.containsKey(property)) { continue; } d = (Xml.Document) new AddProperty(property, String.valueOf(version), null, false) @@ -130,12 +129,8 @@ public Xml.Document visitDocument(Xml.Document document, ExecutionContext ctx) { @Override public Xml.Tag visitTag(Xml.Tag tag, ExecutionContext ctx) { Xml.Tag t = super.visitTag(tag, ctx); - Optional s = t.getValue() - .map(it -> it.replace("${", "").replace("}", "").trim()) - .filter(JAVA_VERSION_PROPERTIES::contains); - if (s.isPresent()) { - propertiesExplicitlyReferenced.add(s.get()); - } else if (JAVA_VERSION_XPATH_MATCHERS.stream().anyMatch(matcher -> matcher.matches(getCursor()))) { + + if (JAVA_VERSION_XPATH_MATCHERS.stream().anyMatch(matcher -> matcher.matches(getCursor()))) { Optional maybeVersion = t.getValue().flatMap( value -> { try { diff --git a/src/test/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersionTest.java b/src/test/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersionTest.java index 969aa2224d..802cf8b71b 100644 --- a/src/test/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersionTest.java +++ b/src/test/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersionTest.java @@ -78,7 +78,7 @@ void basic() { } @Test - void bringsDownExplicitlyUsedPropertyFromRemoteParent() { + void overrideRemoteParent() { rewriteRun( //language=xml pomXml( @@ -116,18 +116,6 @@ void bringsDownExplicitlyUsedPropertyFromRemoteParent() { example-child 1.0.0 4.0 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - ${java.version} - - - - """, """ @@ -145,19 +133,14 @@ void bringsDownExplicitlyUsedPropertyFromRemoteParent() { 4.0 17 + 17 + 17 + 17 + 17 + 17 + 17 + 17 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - ${java.version} - - - - """) )