Upgrading parents and removing redundant dependency versions if (GTE) #4938
-
My ultimate goal is to upgrade the parent pom of a multi-module Maven project and to remove any project dependency versions that are lower that what the new parent manages. We initially started with The following test, which I added to I'm not entirely convinced this is a bug, so starting here. Do you think this is a bug? :) @Test
void sams() {
rewriteRun(
spec -> spec.recipe(
new CompositeRecipe(
Arrays.asList(
new UpgradeParentVersion("org.springframework.boot", "spring-boot-dependencies", "3.4.1", null, null)
, new RemoveRedundantDependencyVersions(null, null, RemoveRedundantDependencyVersions.Comparator.GTE, null)
)
)
),
pomXml("""
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.0</version>
</parent>
<groupId>cool.stuff</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child</module>
</modules>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>
</project>
""", """
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.4.1</version>
</parent>
<groupId>cool.stuff</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child</module>
</modules>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
</project>
"""),
mavenProject("child", pomXml("""
<project>
<parent>
<groupId>cool.stuff</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>
</project>
""",
"""
<project>
<parent>
<groupId>cool.stuff</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
</project>
"""
))
);
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Not an answer (too bad you can can't comment on the OP).. But one of the issues/discussions I refer to above is #4232. I'm not entirely sure these are related, but I suspect they are. I thought there was an issue opened by someone else that I commented on, but I can't find it:( |
Beta Was this translation helpful? Give feedback.
-
Closing this as I created this issue. I know it's not a PR, but better than this open discussion:) |
Beta Was this translation helpful? Give feedback.
Thanks for the runnable example! I'd indeed lean towards calling this a bug. Feel free to start a draft PR with just that test even if you don't know or plan to solve it just yet. Having an easy way to dive in with the debugger already helps; also if we can rebase in the future when making related changes to see if those help.