Or, what if you allowed a source file to be given as an attribute to
taskdef? Then, if a source file is set, it is built and then loaded. So:

<compileTask srcdir="src" destdir="lib">
        <taskdef name="xslt" classname="Xslt"/>
</compileTask>

Works as normal, but

<compileTask srcdir="src" destdir="lib">
        <taskdef name="xslt" src="Xslt.java"/>
</compileTask>

executes an implicit javac on src/Xslt.java before loading it into ant.

Or, on a slightly less serious note, you could create a classloader which
compiles the class first...

On Wed, 21 Jun 2000, James Duncan Davidson wrote:

> on 2000/06/18 19:49, [EMAIL PROTECTED] at [EMAIL PROTECTED]
> wrote:
> 
> > What if we allow all tasks (as opposed to just properties and taskdefs) to
> > be used outside of targets , and execute them on the spot? They would be
> > similar to "static {...}" blocks in java, in that they get run as soon as
> > the class/project is loaded. So at the top of your build file you could
> > just put the following, which would cause the javac task to run before the
> > taskdef:
> > 
> > <project name="foo">
> > 
> > <javac srcdir="lib" destdir="lib"/>
> > <taskdef name="xslt" classname="Xslt" classpath="lib"/>
> > 
> > <target name="bar">
> > ...
> 
> I'm of mixed feelings on this. On the one side, I don't like what's below,
> on the other, I'm not sure I like the idea of static {...}...
> 
> > Or, if we decide to wait until execution time to instantiate tasks, we
> > could add a "target" attribute to taskdef, which would cause that target to
> > be built before loading the task class:
> > 
> > <project name="foo>
> > <taskdef name="xslt" classname="Xslt" classpath="lib" target
> > ="xslt-compile"/>
> 
> Or this could be just a "depends" attrib.
> 
> 
> 

-- 
Tom Cook - Software Engineer

"The brain is a wonderful organ. It starts functioning the moment you get
up in the morning, and does not stop until you get into the office."
        - Robert Frost

LISAcorp - www.lisa.com.au

--------------------------------------------------
38 Greenhill Rd.          Level 3, 228 Pitt Street
Wayville, SA, 5034        Sydney, NSW, 2000

Phone:   +61 8 8272 1555  Phone:   +61 2 9283 0877
Fax:     +61 8 8271 1199  Fax:     +61 2 9283 0866
--------------------------------------------------



Reply via email to