ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <>
Subject Re: using one task in another, project.createTask()
Date Thu, 16 Jun 2005 08:56:28 GMT
Anderson, Rob (Global Trade) wrote:
> Ant Gurus, I am having a little trouble using the XSLTProcess task from within the logger/listener
that I am writing. Here is the code that is causing me greif:
>   XSLTProcess xslt = (XSLTProcess) project.createTask("xslt");
>   xslt.setBasedir(new File("."));
>   xslt.setIn(new File("log.xml"));
>   xslt.setOut(new File("log.html"));
>   xslt.execute();
> I don't thing I am calling the project.createTask() correclty, the xslt object is null
when I step through this with the degugger. Any help is appreciated.


I would recommend that you actually go

XSLTProcess xslt=new XSLTProcess();

then bind it to the owner. Ant1.7 has a method in Task to do that, which 
you will need to adapt into your own code if you want to work on ant1.6:
      * Bind a task to another; use this when configuring a newly created
      * task to do work on behalf of another.
      * Project, OwningTarget, TaskName, Location and Description are 
all copied
      * @param owner owning target
     public final void bindToOwner(Task owner) {

The reason for doing it this way is that
1. you are isolated from any surprises if people use <presetdef> to 
change the class that task "xslt" maps to
2. you can be sure that the task is created right.
3. stuff like the error line and name propagates down correctly.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message