You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Mads Andersen <ma...@pop.k-net.dk> on 2000/09/19 20:34:03 UTC

Lazy evaluation of custom taskdefs

Now that Ant can finally find my custom tag, I have a minor suggestion.

My build.xml has a custom task in the beginning of the file as follows:

  <taskdef name="transform"
classname="com.madsie.util.xsl.XSLTransformTask"/>

Now, XSLTransformTask is a part of the project, so after an "ant clean" the
XSLTransformTask.class is no longer accessible. No matter which target you
try with Ant, it will fail because the Class of XSLTransformTask is resolved
before any targets get executed.

What I would like is to make my targets using taskdef transform ensure that
XSLTransformTask.java is compiled. This would be possible if custom taskdefs
were evaluated in a lazy fasion, that is when the custom tasdef is first
needed.

Best regards, Madsie


Re: Lazy evaluation of custom taskdefs

Posted by Mads Andersen <ma...@pop.k-net.dk>.
>  MA> This would be possible if custom taskdefs were evaluated in a
>  MA> lazy fasion, that is when the custom tasdef is first needed.
>
> They are, but somewhat different than you propose.
>
> You can now (1.2alpha3) put the taskdef into a target and it will be
> evaluated at runtime.
>
> <target name="build.and.define.task">
>   <javac ... />
>   <taskdef name="transform"
>                 classname="com.madsie.util.xsl.XSLTransformTask"/>
> </target>
>
> <target name="use.task" depends="build.and.define.task">
>   <transform ... />
> </target>
>
> Should work - i.e. if it doesn't you've found a bug.

Jose Alberto Fernandez was very kind to point this out to me already. It
didn't work right away though, but switching from the nightly build to the
CVS tree did the trick.

Best regards, Madsie


Re: Lazy evaluation of custom taskdefs

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "MA" == Mads Andersen <ma...@pop.k-net.dk> writes:

 MA> This would be possible if custom taskdefs were evaluated in a
 MA> lazy fasion, that is when the custom tasdef is first needed.

They are, but somewhat different than you propose.

You can now (1.2alpha3) put the taskdef into a target and it will be
evaluated at runtime. 

<target name="build.and.define.task">
  <javac ... />
  <taskdef name="transform" classname="com.madsie.util.xsl.XSLTransformTask"/>
</target>

<target name="use.task" depends="build.and.define.task">
  <transform ... />
</target>

Should work - i.e. if it doesn't you've found a bug.

You might need to use the nested classpath element of taskdef if your
freshly compiled task is not inside of Ant's classpath.

Stefan