Groovy doesn’t support overloaded setters and properties: https://jira.codehaus.org/browse/GROOVY-2500
We could support it though as we have our own dynamic layer. This would be a divergence from Groovy behaviour and only work for Gradle managed objects though. On 5 June 2014 at 11:42:26 am, Xavier Ducrohet (x...@google.com) wrote: I have something like that looks like this: foo { myProp = 9 } The class being configured (represented by foo) has 2 different SetMyProp. One receives an instance of a class 'Bar' and the other one an int. Gradle fails with Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '9' with class 'java.lang.Integer' to class 'Bar' at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.setProperty(BeanDynamicObject.java:192) at org.gradle.api.internal.BeanDynamicObject.setProperty(BeanDynamicObject.java:117) at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:101) at com.android.build.gradle.internal.dsl.GroupableProductFlavorDsl_Decorated.setProperty(Unknown Source) When I saw this, I added a new setMyProp that receives an Integer, but this failed the same way. Editing build.gradle with foo { myProp 9 } Made it call my custom myProp() method, of which there are 3 version (receiving an int, an Integer, and finally an instance of 'Bar'), and it chose the right one. Note that there is a single getter than returns an instance of Bar so I'm wondering if this forces setProperty to use the matching getter. Still this is not very convenient. Anyway to work around that? thanks. — Luke Daley Gradleware Join us for Gradle Summit 2014, June 12th and 13th in Santa Clara, CA: http://www.gradlesummit.com