Skip to content

Spring Boot upgrades (any version) now causes upgrade to Testcontainers 2 #850

@DidierLoiseau

Description

@DidierLoiseau

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.67.0
  • Maven plugin v6.23.0
  • rewrite-recipe-bom 3.19.0 with rewrite-spring 6.19.0

How are you running OpenRewrite?

I am using the Maven plugin (from command-line), and my project is a multi module project.

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

Upgrade a Spring Boot project that depends on Testcontainers – whose version is normally managed by Spring – to Spring Boot 2.x or 3.x (not 4.x as it depends on Testcontainers 2).

What did you expect to see?

The version of Testcontainers remains managed by Spring, and it still uses the old module names.

What did you see instead?

Migration to Testcontainers 2 is executed.

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

[WARNING] Changes have been made to pom.xml by:
[WARNING]         org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_5
[WARNING]             org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_4
[WARNING]                 org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
[WARNING]                     org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2
[WARNING]                         org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1
[WARNING]                             org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0
[WARNING]                                 org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7
[WARNING]                                     org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_6
[WARNING]                                         org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5
[WARNING]                                             org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_4
[WARNING]                                                 org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration
[WARNING]                                                     org.openrewrite.java.testing.junit5.JUnit4to5Migration
[WARNING]                                                         org.openrewrite.java.testing.junit5.UseMockitoExtension
[WARNING]                                                             org.openrewrite.java.testing.mockito.Mockito1to4Migration
[WARNING]                                                                 org.openrewrite.java.testing.mockito.Mockito1to3Migration
[WARNING]                                                                     org.openrewrite.java.testing.mockito.AnyToNullable
[WARNING]                                                         org.openrewrite.java.testing.junit5.ExcludeJUnit4UnlessUsingTestcontainers
[WARNING]                                                             org.openrewrite.java.testing.testcontainers.Testcontainers2Migration
[WARNING]                                                                 org.openrewrite.java.testing.testcontainers.Testcontainers2Dependencies
[WARNING]                                                                     org.openrewrite.java.dependencies.ChangeDependency
[WARNING]                                                             org.openrewrite.maven.ExcludeDependency

According to me, Testcontainers 2 migration should only be applied with Spring Boot 4. It should thus not be included as part of JUnit 5 migration.
Maybe it can be done before UpgradeSpringBoot_3_5 recipe, so that the JUnit 4 dependency exclusion works properly?

Moreover, the exclusion recipe should not rely on DoesNotIncludeDependency spring-boot-testcontainers, but it should check for Testcontainers 1.x instead – if you use Testcontainers 2 through spring-boot-testcontainers, it still makes sense to add the JUnit 4 exclusion to other dependencies.

Are you interested in contributing a fix to OpenRewrite?

  • I’d be ok with reverting the changes to ExcludeJUnit4UnlessUsingTestcontainers from Upgrade testcontainers for the JUnit 5 migration #833 and add Testcontainers2Migration to the SB 4 recipe (although to be honest, we are only getting to 3.5 now, so I can’t test it much 😓).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions