Skip to content

UpgradeJavaVersion leaves behind stale unused properties #668

@sushmitha-malae

Description

@sushmitha-malae

What version of OpenRewrite are you using?

I am using

  • rewrite Maven plugin v5.45.0

How are you running OpenRewrite?

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
   </properties>
   
   <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                   <source>${maven.compiler.source}</source>
                   <target>${maven.compiler.target}</target>
                </configuration>
   </plugin>

I see the following changes after the recpie got executed.

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
   </properties>
   
   <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                   <release>21</release>
                </configuration>
   </plugin>

My expectation

    <properties>
   </properties>
   
   <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                   <release>21</release>
                </configuration>
   </plugin>

I apply UpgradeJavaVersion Recipie for Java 21 upgradation
As part of the recpie's execution
Firstly, source and target tags are replaced by release tag with 21 value
Secondly, maven.compiler.source and maven.compiler.target property values are updated to 21 value

What did you expect to see?

If the property maven.compiler.source and maven.compiler.target are removed as part of first recpie execution, then why to update the removed properties and keep them in the code.

This leads to stale and unused properties.

I was expecting if the properties are not use, the properties also should be removed as part of recpie.

Are you interested in contributing a fix to OpenRewrite?

I am interested in contributing to this.
Want to know if the expectation of mine is valid or not.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions