[GRADLE-352] Cannot call a convention method called 'source' from build script Created: 08/Jan/09  Updated: 04/Jan/13  Resolved: 20/May/09

Status: Resolved
Project: Gradle
Affects Version/s: 0.5
Fix Version/s: 0.6

Type: Bug
Reporter: Adam Murdoch Assignee: Adam Murdoch
Resolution: Fixed Votes: 0


 Description   

I have a convention object with a method called 'source' and I cannot call it from a build script. I can call other methods on the same convention object - just not the source() method.

Here's some sample code:

convention.plugins.bean = new Bean()
someMethod() // works
source() // fails with a groovy exception

class Bean {
def someMethod()

{ println 'in someMethod()' }

def source()

{ println 'in source()' }

}



 Comments   
Comment by Hans Dockter [ 07/Apr/09 ]

This problem has to do with the ScriptWithSource class and its setSource method. The stacktrace is confusing. I guess Groovy checks first if Script has a source method. If not it checks if there is a source property. Because of the setSource method it thinks there is one, but that it is not readable. Renaming the setter to setScriptSource would make this problem more unlikely to occur. We might even choose even more uncatchy names for those methods. An alternative would be not to extend Script at all.

Comment by Adam Murdoch [ 20/May/09 ]

I've renamed the setter to setScriptSource(). Not a particularly good fix, but it will do for now.

Generated at Wed Jun 30 11:27:58 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.