Support usage in projects using Gradle 8.10 by avoiding using Project.equals#257
Conversation
… Project inequivalence in newer Gradle versions
|
|
|
Thanks for this, first thing I've found is the sample app's If you could push up a fix for that I can run the CI and get some tests going |
Oops! I didn't notice that the sample was being configured separately from the plugin 😅 Updated the sample app to compile. |
I can't find anything in the Gradle 8.10 release notes or issue tracker, but we've found that the affected module detector (both versions 0.3.1 and 0.3.0) stops working on Gradle 8.10.
Using 0.3.1 we are seeing that no tasks will run and AMD always sees that no modules have changed. I downgraded our integration to 0.3.0 to obtain logs and work around #205, and saw that AMD is correctly identifying all the changed modules, but when it goes to identify whether those changed modules should be included in the build, it always returns
falsefor every module.I suspected that the cause was the use of
Set<Project>and subsequent usage ofSet.contains(Project), which would rely on theProjectintrinsicequalsimplementation. NeitherProjectnorDefaultProjectimplementequals, and it seems like separateProjectinstances are getting created now in Gradle 8.10 (I'm not sure why). As a result, the defaultequalsimplementation is returningfalsewhen checking equivalent projects. I added this repository as an included build and updated the usage ofSet<Project>toMap<String, Project>whereStringwas the project path, and AMD worked as expected.This MR updates the usage of
Set<Project>toMap<ProjectPath, Project>whereProjectPathis a value class that wraps the path. It updates the tests to expectMap<ProjectPath, Project>instead ofSet<Project>, but it does not update the Gradle version. Note: I didn't update the Gradle version so that we don't potentially lock out consumers on older Gradle versions from using AMD.I can work on a repro project containing both Gradle 8.9 and 8.10, if needed, to demonstrate the issue.