Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties not removed after running recipe RemoveRedundantDependencyVersions #4350

Open
wesboe opened this issue Jul 23, 2024 · 2 comments
Open
Labels
enhancement New feature or request recipe Requested Recipe

Comments

@wesboe
Copy link

wesboe commented Jul 23, 2024

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

@timtebeek
Copy link
Contributor

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?

@timtebeek timtebeek added recipe Requested Recipe enhancement New feature or request labels Jul 23, 2024
@timtebeek timtebeek changed the title Properties not removed after running recipe RemoveRedundantDependencyVersions Properties not removed after running recipe RemoveRedundantDependencyVersions Aug 22, 2024
@HelloDhero
Copy link

I think if this is deleted, it will bring many side effects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request recipe Requested Recipe
Projects
Status: Recipes Wanted
Development

No branches or pull requests

3 participants