`AddDependency` fails to add `jakarta.xml.bind-api` after Gradle `UpgradePluginVersion` updates `org.springframework.boot` to `3.0.x`
Failure to add xml bind dependency via Rewrite Gradle plugin for Spring Boot 2.x -> 3.x upgrade
- https://github.com/openrewrite/rewrite/issues/6411
Thanks for the runnable report! Did you already explore why this might be occurring as well?
I was only able to see when this got broken but I wasn't able to see what exactly is broken... Still investigating...
I've created this PR to run tests via CI... I'm having a lot of issues running tests that make gradle tooling api connections on my machine... I constantly run into some lock issues in gradle cache or class file version issues...
Let me explain a bit what I'm trying to fix.
I'm upgrading spring-petclinic 2.7.x to 3.0.x. The upgrade process should add the dreaded XML Bind API dependency. It works fine for Maven but for Gradle it does not add the dependency. It used to work fine before Rewrtite Gradle Plugin 7.9.0 and rewrite-spring 6.9.0. The last version combination where the dependency was added is gradle plugin 7.8.0 and rewrite-spring 6.8.2.
I'm sure the issue is in rewrite-gradle 8.55.2 and above... I'm thinking that after upgrading gradle plugin version the dependencies graph isn't updated hence the recipe doesn't know the XML Bind API dependency needs to be added. The dependencies graph might not be updated due to the 3.0.x boot plugin not working with 7.x gradle (???). Investigating.
@timtebeek feel free to give a direction to my investigation if you feel I'm going off the rails ;-)
@timtebeek this is the change in 8.55.2 that breaks the 8.55.1 behaviour: https://github.com/openrewrite/rewrite/compare/v8.55.1...v8.55.2#diff-743cf2f048fdba39228e626dd60acbdf76b3f256061b826bffd26106e95338abL241
I've ported that change in the PR. However, I think what the code was doing in main is correct... I think the actual problem is that after updating gradle plugin version (boot plugin 2.7.x -> 3.0.x) the GradleProject marker isn't updated. The MavenResolutionResult is updated if dependency management bit changes via a recipe. The Maven marker is re-resolved "manually", however, I don't see this in the Gradle variant and not sure if this is possible at all... It's okay for something small like a dependency add/change/remove and this is implemented but for a plugin (i.e. dependency management) I'd involve the gradle to do the job somehow.
Thanks for digging in! Let me tag @shanman190 for his insights here while I'm out.