When a gradleApi dependency doesn't respond as expected when contentEquals is called with parameter gradleApi that is a new instance

I am trying to write a plugin that will do things specific when someone adds the gradleApi() as a dependency. I tried to use the contentEquals method but it will always return false when the objects being compared are different instanced of dependencies.gradleApi()

Script:

apply plugin: 'java'
println dependencies.gradleApi().contentEquals(dependencies.gradleApi())

Result:

❯ gradle build
false
:compileJava UP-TO-DATE

I have made a patch that would allow users to be able to determine what kind of dependency was added, when its a classpath type (gradleApi, lovalGroovy).

https://github.com/ethankhall/gradle/tree/make-gradle-api-dependency-work-as-expected

I’ve fixed this for 2.4.

Thanks for the report.