-
Notifications
You must be signed in to change notification settings - Fork 349
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
Expand GradleDependency Trait to change dependencies in jvm-test-suite DSL & buildscript #4376
Expand GradleDependency Trait to change dependencies in jvm-test-suite DSL & buildscript #4376
Conversation
rewrite-gradle/src/test/java/org/openrewrite/gradle/ChangeDependencyTest.java
Outdated
Show resolved
Hide resolved
rewrite-gradle/src/test/java/org/openrewrite/gradle/ChangeDependencyTest.java
Outdated
Show resolved
Hide resolved
Great to see this replicated, thanks! Did you already step through using this test as well? |
No problem. I haven't stepped through yet. I am about to go on vacation for a week so will hopefully pick it up on my return unless someone else does. |
Ah thanks a lot for logging the issue before logging off; enjoy your time off! We'll see if some of the usual suspects gets to it before you return. ;) |
…st-case-for-changing-dependencies-in-jvm-test-suites
…JVM Test Suite plugin to make the failing test pass.
…-suites' of github.com:sihutch/rewrite into failing-test-case-for-changing-dependencies-in-jvm-test-suites
@sihutch and @ryanwalker, I just noticed that both of you are working on the same update to the same recipe. Would one of you like to perform the updates on ChangeDependency while the other does the same for UpgradeDependency? This way you'd both get the experience and it'd help out 2 of the many Gradle recipes needing this particular update. This is Ryan's PR that he's working on presently: |
@shanman190 @ryanwalker - I am happy to wait for Ryan to complete his PR on ChangeDependency and then work for UpgradeDependency. Once we have a working solution, it should be straightforward to extract any commonality. |
…in-jvm-test-suites
…d in jvm-testsuites
… in jvm-testsuites
…in jvm-testsuites
…ed in the buildScript
|
||
GradleDependency.Matcher gradleDependencyMatcher = new GradleDependency.Matcher(); | ||
|
||
if (!gradleDependencyMatcher.get(getCursor()).isPresent() || !(StringUtils.isBlank(configuration) || m.getSimpleName().equals(configuration))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An additional enhancement here would be to expose configuration
as another selector for the matcher. This isn't strictly necessary as part of this PR though, but I wanted to mention it while I was here.
For tests 1-3, I'd expect for these to work. I'll try to debug these a little bit locally. EDIT:
|
@timtebeek, do you have any ideas or opinions on how one might address test cases 2 or 3 from my analysis above? For the project dependency, we could build enough of a The subprojects block dependencies is a harder problem as we've gotten by so far by abusing the current project, but that's not really sustainable. Gradle's configuration cache/project isolation feature will help as teams adopt it as it explicitly disallows this from happening on modern projects. |
…in-jvm-test-suites # Conflicts: # rewrite-gradle/src/test/java/org/openrewrite/gradle/UpgradeDependencyVersionTest.java
I've pushed a fix for this. I have also removed tests 4 and 5 I have resolved merge conflicts, but this has resulted in a new failing test case
|
Yeah, I was just looking at that new test last night. For the standalone scripts, they aren't carrying a |
I'm wondering if we won't have to make a concession for these 3 failing tests by just retaining the old path as a fallback. This would ultimately only effect the |
I would definitely do this. It seems a shame to hold back the otherwise useful functionality. @shanman190 in my original PR I I reduced a predicate class that fell back to the old method in the case where the trait failed. Do you think it is worth introducing such a mechanism again for all cases? |
@sihutch, rather than the predicate, I think I'd probably update all of the references to first check with the As it relates to the predicate, I don't think the increase in API surface area is worth the indirection at the moment given the above. |
…n and UpgradeDependencyVersion cases
@shanman190 I have implemented the fallback for the |
Awesome! I'll probably do a small cleanup commit tomorrow, but then we'll get this merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeDependencyVersion.java
- lines 375-374
rewrite-gradle/src/test/java/org/openrewrite/gradle/UpgradeDependencyVersionTest.java
Outdated
Show resolved
Hide resolved
…endencyVersionTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…in-jvm-test-suites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeDependencyVersion.java
- lines 375-374
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the detailed work here! I've adapted the PR title before that becomes the squashed commit message; I hope I covered the essential well there.
Sure nice to see complexity concentrated into that GradleDependency Trait, and reused from each of the individual recipes.
Thanks as well to @shanman190 for the continued guidance on this PR; I'll let you merge since you mentioned you were planning a slight polish as well.
Thanks @timtebeek. It was a good learning experience, and I appreciate the detailed guidance from @shanman190. I am a platform team member managing change for hundreds of projects. This is my first time using OpenRewrite for migration, and it is proving very useful. Thanks to the team. I hope to make more contributions in the future. |
@sihutch, thanks again for all of the work put in on this! |
@shanman190, we are heavy users of test suites so this improvement is great for us. Thanks for your patience and detailed responses. I really appreciate it and have learned a lot through the process. |
What's changed?
Dependencies configured within a test suite are not updated by the org.openrewrite.gradle.ChangeDependency recipe.
This PR has only a failing test case. I would be happy to try to contribute a fix but I would need a lot of pointers to get me started.
What's your motivation?
We are heavy users of the Test Suites and would like to be able to upgrade their dependencies using OpenRewrite.