Properties not removed after running recipe `RemoveRedundantDependencyVersions`
What problem are you trying to solve?
The RemoveRedundantDependencyVersions recipes removes redundant version of dependencies. But when the version is a property, the property is not removed. Impact Unused properties in your pom.xml or you override the property of a parent pom. For example Spring Boot has Managed Dependency Coordinates in their parent pom spring-boot-dependencies.
What precondition(s) should be checked before applying this recipe?
We can limit the execution to Maven.
Describe the situation before applying the recipe
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
</parent>
<artifactId>example</artifactId>
<properties>
<logback.version>1.4.7</logback.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
Describe the situation after applying the recipe
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
</parent>
<artifactId>example</artifactId>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
Have you considered any alternatives or workarounds?
For the properties managed by Spring Boot you can use the recipe to remove a property tag and add all properties managed by Spring Boot.
Any additional context
Are you interested in contributing this recipe to OpenRewrite?
Yes I would like to contribute
Thanks for logging an issue @wesboe ! I'm doubting between whether this should be a standalone recipe or whether it should be part of RemoveRedundantDependencyVersions. Note that RemoveRedundantDependencyVersions could also call a separate recipe to clean up properties used in removed dependency version tags.
Either way the tricky part is knowing if a property really isn't used anymore. It could still be referenced elsewhere in the same pom.xml, or in a parent or child pom.xml file. Any thoughts as to how you had wanted to cover such cases? Perhaps at first only removing property versions that are also present in a parent to minimize disruption?
I think if this is deleted, it will bring many side effects