openrewrite / rewrite-spring

OpenRewrite recipes for Spring projects.
Apache License 2.0
237 stars 64 forks source link

Maven dependency added with invalid classifier when using LocalServerPort #541

Closed eocantu closed 1 week ago

eocantu commented 2 weeks ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi-module project: https://github.com/eocantu/spring-boot-demo

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

The project referenced above is a minimalistic multi-module project using LocalServerPort. The error can be recreated as follows:

git clone https://github.com/eocantu/spring-boot-demo
cd spring-boot-demo
./mvnw rewrite:run

What did you expect to see?

I expected to not see a dependency added, or if it was added, not added with a classifier.

What did you see instead?

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>3.2.7</version>
            <classifier>org.springframework.boot.web.server.LocalServerPort</classifier>
            <scope>test</scope>
        </dependency>

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

No errors observed

timtebeek commented 2 weeks ago

Thanks for the quick reproducer! Looking at this recipe I think the arguments have shifted such that we accidentally pass in LocalServerPort as a classifier. Likely an easy fix. Is that something you'd be willing to contribute? https://github.com/openrewrite/rewrite-spring/blob/24af0a4b05b8620028611bc1dfc15fa981a02eb7/src/main/java/org/openrewrite/java/spring/boot2/MigrateLocalServerPortAnnotation.java#L64-L74