Correctly override parent property to set Java version#549
Correctly override parent property to set Java version#549timtebeek merged 10 commits intoopenrewrite:mainfrom
Conversation
8f9f6ab to
57d617b
Compare
|
Much appreciated to have this runnable @DidierLoiseau ! Did you already look into a potential fix following the commit you referenced? I'm a little behind on reviews, but will try to get to this one as well if you can't work out a fix already, as I understand the frustration of seeing a needless |
No, I’m new to OpenRewrite. I just quickly glanced over the commits of v21.0 and noticed one was a big refactoring/rewrite of There is a side-question to this which is: which property should actually be set by |
|
I have moved the test to Assuming the parent poms are properly written, there should probably be a single property to override, and the other properties should derive from it. Based on this, I think a solution could be to check in |
bfcc1f3 to
2ad6738
Compare
In the end it seems to be commit 12c8f37 combined with that commit which caused the issue: the former was only taking into account properties used in the current pom, while the latter was adding I don’t really understand the purpose of 12c8f37: if the parent defines a property, it’s certainly to be used by the parent (like in Spring Boot) so we have to update it. I doubt there is a use case where you wouldn’t want that, but that commit didn’t reference a specific issue number. I thus implemented a fix that reverted it – all properties from the (remote) parent are now overridden when they have a numeric value. With Spring Boot for example, this means that only If this is not satisfying, I think the only solution would be to parse the There are still 2 limitations (already there before):
|
2ad6738 to
2369654
Compare
src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersion.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/maven/UpdateMavenProjectPropertyJavaVersionTest.java
Outdated
Show resolved
Hide resolved
… referenced explicitly" This partially reverts commit 12c8f37
…arent, but smartly - only override numeric values - if any property is detected, don't add maven.compiler.release
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
e106863 to
7afbde7
Compare
|
Thanks a lot for the work already done here @DidierLoiseau ! I've tried for a bit to get the new failures in
We usually see that if a recipe unconditionally makes a change, as opposed to only when the existing value does not match the target value. Could be good to have @sambsnyd weigh in indeed, as I've seen reports of these excess properties over the past week or so. |
Need to update the model because we are working with the resolved properties now, not the requested ones.
|
@timtebeek I fixed the test. The problem was related to the second comment I made: previously, the code was working with It does not look like there is a convenient way to do that, so I just used |
|
Actually, there seems to be a bug in Previously it was working because Side note: when visitors instantiate and call other visitors which call |
timtebeek
left a comment
There was a problem hiding this comment.
I like the simplifications done here with increased focus, and pointing to UseMavenCompilerPluginReleaseConfiguration where a change would be out of scope for this particular recipe. The added tests for common cases in practice will help guard regression in the future. Thanks a lo!
What's changed?
UpdateMavenProjectPropertyJavaVersionTestexpecting no change when upgrading to Java 17 but parent is already spring-boot 3.3 (declaresjava.versionandmaven.compiler.releasewith value 17 already) .maven.release.pluginonly when no release property is foundWhat's your motivation?
maven.compiler.releaseset in parent is not recognized in child module #523Checklist