Skip to content

Commit

Permalink
Partially revert "Only bring down properties from the parent that are…
Browse files Browse the repository at this point in the history
… referenced explicitly"

This partially reverts commit 12c8f37
  • Loading branch information
DidierLoiseau committed Sep 18, 2024
1 parent 010642d commit b446840
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public String getDescription() {
@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new MavenIsoVisitor<ExecutionContext>() {
final Set<String> propertiesExplicitlyReferenced = new HashSet<>();
boolean compilerPluginConfiguredExplicitly;

@Override
Expand All @@ -99,7 +98,7 @@ public Xml.Document visitDocument(Xml.Document document, ExecutionContext ctx) {
MavenResolutionResult mrr = getResolutionResult();
Map<String, String> 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)
Expand Down Expand Up @@ -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<String> 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<Float> maybeVersion = t.getValue().flatMap(
value -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void basic() {
}

@Test
void bringsDownExplicitlyUsedPropertyFromRemoteParent() {
void overrideRemoteParent() {
rewriteRun(
//language=xml
pomXml(
Expand Down Expand Up @@ -116,18 +116,6 @@ void bringsDownExplicitlyUsedPropertyFromRemoteParent() {
<artifactId>example-child</artifactId>
<version>1.0.0</version>
<modelVersion>4.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
""",
"""
Expand All @@ -145,19 +133,14 @@ void bringsDownExplicitlyUsedPropertyFromRemoteParent() {
<modelVersion>4.0</modelVersion>
<properties>
<java.version>17</java.version>
<javaVersion>17</javaVersion>
<jdk.version>17</jdk.version>
<jdkVersion>17</jdkVersion>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<release.version>17</release.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
""")
)
Expand Down

0 comments on commit b446840

Please sign in to comment.