Removing managed dependency problem: Upgrade parent version or remove redundant version recipe (GTE) #4949
Labels
bug
Something isn't working
test provided
Already replicated with a unit test, using JUnit pioneer's ExpectedToFail
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 UpgradeParentVersion, but doesn't seem to work well with modules. I'm suspicious that UpgradeMavenModel isn't propagating all changes to the 'POM tree', but I may be misunderstanding how that works. I have a few other issues/comments about this (apologies for not linking yet). Regardless, in later recipes we are messing with dependencies , so added a RemoveRedundantDependencyVersions recipe at the end. This covers multiple cases that you'd think would be covered by UpgradeParentVersion, but it doesn't seem to handle the case where if a.group:a.artifact:1.0 did not exist in the old parent, but does in the new. In that case, we expect all project usage of a.group:a.artifact:1.0 to be replaced with a.group:a.artifact (no version).
The following test, which I added to UpgradeParentVersionTest, is the shortest form of what we're experiencing. jakarta.annotation-api was added in spring-boot-dependencies:3. When you run, you will see that dependency version does not get removed from the child module pom. If you only run UpgradeParentVersion in the test (remove RemoveRedundant..), you'll see neither gets removed. If I bring that back and set onlyIfManagedVersionIs to ANY, it does remove it. However, we don't want to override project-level dependencies that are higher than what we manage.
Originally posted in this discussion
What version of OpenRewrite are you using?
Test below was run on that
main
branch in therewrite-maven
moduleWhat is the smallest, simplest way to reproduce the problem?
The text was updated successfully, but these errors were encountered: