-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UpgradeDependencyVersion does not update dependency version whose value is defined via a property from the parent POM #4193
Comments
@timtebeek could you please take a look and let me know if there’s a plan to support this? |
Hi @nguyenhoan ; Thanks for the detailed report. Are changes made to the root pom when there is no module 2, just module 1? Or do both modules have to exist before the recipe only applies changes to module 2? The relevant parts of the recipe are likely here rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/UpgradeDependencyVersion.java Lines 219 to 223 in ea566dc
We'd maybe need to revise the logic a bit if we want to (additionally) bump properties that are in a parent that's part of the same project. Your examples above converted into a unit test could be good step in that direction. |
Thanks for your response!
Module 2 does not have to be there to reproduce the issue.
Can you share an example of a test case using parent and child |
Sure! Here's an example that uses a parent pom.xml and then a child project that uses that parent. rewrite/rewrite-maven/src/test/java/org/openrewrite/maven/UpgradeDependencyVersionTest.java Lines 265 to 329 in d6417f2
Notice that you'll want to remove the |
Thanks for the pointers!
|
Thanks for reducing this down to a unit test! As an implementation note rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/UpgradeDependencyVersion.java Line 51 in 74faca0
|
Thanks for the note! Would you be able to help with the implementation? I could figure out how to check if a version refers a property not defined in the same POM but I am stuck in finding the way to modify across files. |
Sure! Although it might be best to join our Slack to get faster feedback on any questions, also because I'll be traveling for the next two weeks. In general I can say that Scanning Recipes can collect information across files in an Accumulator, which is then accessible when making changes in a second pass over the files. In this case you'll likely want to keep track of properties and their use, such that when it comes to making changes you can update them in the appropriate file. |
That makes sense. The problem is that UpgradeDependencyVersion
This What would be your suggestion? |
Ah thanks for pointing that out and being cautious to break things downstream. I think in this case it's fine as long as we update both in tandem, as we release all modules in tandem every two weeks or so. You'll have noticed the model for Gradle is already different for Maven, so we should be ok to introduce a custom object here too if we need more than just the |
Sounds good. I will try to make progress from my side in my local workspace. I am not sure how the build would work when I create two separate PRs for the two repos though. |
This repository can go first; the change in rewrite-java-dependencies is most likely relatively easy to do comparatively. |
PR to the first repo |
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 two-module project.
What is the smallest, simplest way to reproduce the problem?
Root/Parent
Module 1
Module 2
What did you expect to see?
The property
spring-boot.version
in root/parent POM is updated to3.2.5
.What did you see instead?
The property
spring-boot.version
in root/parent POM is unchanged:2.1.1.RELEASE
. Therefore, Spring Boot in module 1 was not upgraded.What is the full stack trace of any errors you encountered?
Are you interested in contributing a fix to OpenRewrite?
The text was updated successfully, but these errors were encountered: