Ah, that's really interesting. I didn't think about using Ext props to pass 
that along. Neat.

--  
John Engelman


On Wednesday, January 8, 2014 at 12:35 PM, Luke Daley-2 [via Gradle] wrote:

>  
> On 7 Jan 2014, at 6:37 pm, Xavier Ducrohet <[hidden email] 
> (/user/SendEmail.jtp?type=node&node=5712174&i=0)> 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
>  
>  
>  
>  
> If you reply to this email, your message will be added to the discussion 
> below: 
> http://gradle.1045684.n5.nabble.com/declaring-a-class-in-a-gradle-file-and-using-it-through-apply-from-tp5712170p5712174.html
>   
> To start a new topic under gradle-dev, email 
> ml-node+s1045684n1436218...@n5.nabble.com 
> (mailto:ml-node+s1045684n1436218...@n5.nabble.com)  
> To unsubscribe from gradle-dev, click here 
> (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1436218&code=am9obi5yLmVuZ2VsbWFuQGdtYWlsLmNvbXwxNDM2MjE4fDIyMTUyNjEzNQ==).
> NAML 
> (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)
>   





--
View this message in context: 
http://gradle.1045684.n5.nabble.com/declaring-a-class-in-a-gradle-file-and-using-it-through-apply-from-tp5712170p5712175.html
Sent from the gradle-dev mailing list archive at Nabble.com.

Reply via email to