- Notifications
You must be signed in to change notification settings - Fork4.9k
Description
Current Behavior
The equals contract ofProject::equals
is broken when comparing against aLifecycleAwareProject
:LifecycleAwareProject
is equal to its correspondingDefaultProject
but not the other way around.
Expected Behavior
equals()
must be symmetric
Context (optional)
We have a plugin applied on the root project with an extension that maintains aSet<Project>
.
A plugin applied on subprojects checks if the target project is contained in that set.
As of Gradle 8.10, the set now containsLifecycleAwareProject
s and acontains(defaultProject)
check always fails.
Also identity equality is not reliably anymore because ofLifecycleAwareProject
(e.g. in Java code:project.getParent() == project.getRootProject()
). This changed behavior is understandable but might be good to document it in the release notes.
Steps to Reproduce
/build.gradle.kts
project.ext["subproject"]= subprojects.toList()[0]
/subproject/build.gradle.kts
val lifecycleAware= rootProject.ext["subproject"]!!println("$lifecycleAware (${lifecycleAware.javaClass}")println("$project (${project.javaClass}")println(lifecycleAware== project)println(project== lifecycleAware)
This prints
> Configure project :subprojectproject ':subproject' (class org.gradle.api.internal.project.LifecycleAwareProject_Decoratedproject ':subproject' (class org.gradle.api.internal.project.DefaultProject_Decoratedtruefalse
Gradle version
8.10
Build scan URL (optional)
No response
Your Environment (optional)
No response