Fix ChangeDependency to handle unknown configurations
What's changed?
ChangeDependency does not work on configurations it does not understand. This one from my project gets skipped:
integrationTestImplementation "com.github.tomakehurst:wiremock-jre8-standalone:2.+"
I created a GradleDependency Trait to solve this.
What's your motivation?
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist
- [ ] I've added unit tests to cover both positive and negative cases
- [ ] I've read and applied the recipe conventions and best practices
- [ ] I've used the IntelliJ IDEA auto-formatter on affected files
With the recent introduction of the Trait API into rewrite proper, we can instead make use of that to provide an even stronger guarantee that the method invocation is a Gradle configuration.
We could become as strict as to only accept dependency configurations that are meant for holding dependencies by not being consumable or resolvable.
This seems to be getting closer. I'm going to also share the commit with which the MavenDependency trait was introduced which should show a bit better all of the components in place and how it's utilized.
https://github.com/openrewrite/rewrite/commit/c24e9920b509a79a9189402095b905f6ccbd1cd4
All tests are passing now. Its still not prod ready yet but ill clean it up early this week. Let me know if theres anything glaring that anyone thinks should be done differently.
@ryanwalker, I went ahead and extracted the Trait api out from this PR to make this task a little simpler. You can see that PR here:
- https://github.com/openrewrite/rewrite/pull/4394.