Gradle, overload extension setter

I posted a question regarding getting


for overloaded setters for extension properties (for a plugin) in gradle @ stackoverflow - however, the answers don’t really address the problem.

PS: I know this is kinda double posting & I apologize for that…

Simply put, this works in Gradle versions 2.0+. I’ve posted this as an answer on SO.

Not true…

Try the following code in Gradle 2.1 in a random build.gradle file…

class Foo {
     Project proj
       void setProject( Project project) {
            this.proj = project
       void setProject( String project) {
      println 1337;
  project.extensions.create('foo', Foo)
foo {
      project = ':random-project'

It gives me:

This is a limitation of the Groovy language:

That is very strange. The exact snipped that Mazdak posted above works for me in Gradle 2.1. Executing something like ‘gradle tasks’ prints ‘1337’ to the screen.

Luke Daley: Bummer! Thanks for the info, at least now I know it can’t be done =)

Update: I was able to reproduce the failure Mazdak is seeing when using a Java8 JRE. Going back to Java7 seems to work, perhaps though, only incidentally.

Update: Disregard, in that case it simply always calls the ‘String’ setter.

Weird behaviour… I was using jdk1.8… Seems too unreliable to rely on.