On 24/02/10 3:43 PM, James Carr wrote:
Hi All,
I want to be able to define a custom function in a build.gradle that
can be called from subprojects, but I'm not having much luck (it's an
ant task). Essentially I have a function that looks like this:
def run(String clazz){
ant.java(classname: clazz, fork: false,
classpath: "${sourceSets.main.runtimeClasspath.asPath}")
}
One problem with this is that property and method references in the
run() method's body are resolved against the root project. For example
sourceSets will refer to rootProject.sourceSets, rather than
$callingProject.sourceSets, which is possibly not what you want.
Rather than method inheritance, you can use method injection:
subprojects {
run = { String clazz ->
// will use the correct project to resolve stuff
ant.java(....)
}
}
A project property whose value is a closure will be treated as a method.
and want to call it from sub projects like this:
task doSomething<<{
...
run('foo.bar.baz.Main');
}
any ideas?
Thanks,
James
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email