On 7 Jan 2014, at 6:37 pm, Xavier Ducrohet <x...@google.com> wrote: > Hi, > > trying to refactor some internal code, I'm running into another issue with > 'apply from' > > There's a foo.gradle file that only declares a new class extending > DefaultTask, and we're trying to use it from another gradle file after doing > 'apply from: foo.gradle' but it doesn't find the type. > > Is there a way to make this work?
Kind of. Classes defined in script plugins are not visible to their “parents”. They are not on the compile classpath, because script plugin application happens at runtime. Moreover, class references in Groovy are not actually dynamic. So, you have to manually export the class literal across classloader boundaries, making a variable of type class available. This is usually done as a project extra property build.gradle: apply from: "someTaskDefinition.gradle" task fancyTask(type: FancyTask) {} someTaskDefinition.gradle: class FancyTask extends DefaultTask {} ext.FancyTask = FancyTask In build.gradle it looks like you're using a class literal, but it's a project property whose value is a class. -- Luke Daley Principal Engineer, Gradleware http://gradleware.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email