openrewrite / openrewrite/rewrite-spring

spring-boot-22 and -23 recipes are overwriting version placeholder with version

Open
#474 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
403
Forks
149
Avg merge
2h 33m
Merged PRs (30d)
10

Description

What version of OpenRewrite are you using?

I am using

  • Maven/Gradle plugin v5.18.0
  • rewrite-spring v5.1.7

How are you running OpenRewrite?

I am using the Maven command line invokation

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_3

What is the smallest, simplest way to reproduce the problem?

<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 http://maven.apache.org/maven-v4_0_0.xsd">
  <properties>
    <spring.boot.version>2.2.13.RELEASE</spring.boot.version>
    <spring.jms.version>5.2.25.RELEASE</spring.jms.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>${spring.jms.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

What did you expect to see?

<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 http://maven.apache.org/maven-v4_0_0.xsd">
  <properties>
    <spring.boot.version>2.3.12.RELEASE</spring.boot.version>
    <spring.jms.version>5.2.25.RELEASE</spring.jms.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>${spring.jms.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

What did you see instead?

The placeholder ${spring.jms.version} is replaced with the hard coded version. Note that this is not happening for other placeholders like ${spring.boot.version} in the file.

<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 http://maven.apache.org/maven-v4_0_0.xsd">
  <properties>
    <spring.boot.version>2.2.13.RELEASE</spring.boot.version>
    <spring.jms.version>5.2.25.RELEASE</spring.jms.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>5.2.25.RELEASE</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

What is the full stack trace of any errors you encountered?

No errors.

Are you interested in contributing a fix to OpenRewrite?

I currently lack the time to do so unfortunately.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Maven command and the org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_3 recipe, using the supplied pom.xml as the reproduction. Compare the expected and actual handling of ${spring.jms.version}; done means the placeholder remains while spring.boot.version upgrades to 2.3.12.RELEASE.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.