Redundant JUnit 5 dependency added to Maven pom.xml after Spring Boot 1 -> 2 migration
I ran the org.openrewrite.java.spring.boot2.SpringBoot1To2Migration recipe and it added these two dependencies to the pom.xml file, which isn't needed when using Spring Boot 2.2 (I believe) or later.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
Also, there's no need to exclude JUnit 4 from the Spring Boot test-starter, i.e.:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
isn't necessary, this is enough:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Moving this back to the back-log.
The unnecessary JUnit 5 dependency is caused by adding both the spring-boot-starter-test and the junit-jupiter-engine dependencies. An approach to this issue would be a new recipe for removing unnecessary dependency tags because they are also transitive.
Would it also be possible to add a generic recipe to remove dependency exclusions when no longer transitively part of a dependency?
That could also help clear up the unnecessary junit exclusions, apart from the explicit calls to remove that and the ordering issues that come with it as discussed in https://github.com/openrewrite/rewrite-spring/issues/175#issuecomment-1079311068.
There have been quite a few changes to the underlying recipes in the past three years, and I've not had anymore reports about this being an issue. If this remains a problem do please let us know.