Russ Bateman
Russ Bateman

Reputation: 18643

Where to put JAR containing custom ant task?

I've created a custom ant task according to Apache doc.

Running ant, I get:

BUILD FAILED
/home/russ/blackpearl/fun/build.xml:92: taskdef class com.etretatlogiciels.ant.task.SqlScriptPreprocessor cannot be found using the classloader AntClassLoader[]

I have the following in build.xml prior to my use of

<taskdef name="sqlscriptpreprocessor" classname="com.etretatlogiciels.ant.task.SqlScriptPreprocessor" />

...and I've dropped a copy of sqlscriptpreprocessor.jar into my local lib subdirectory (should be on classpath) and even into /usr/bin/ant/lib (which is apache-ant-1.8.2).

Where should this go? Or what other problems are anticipated that I should look for?

Thanks very much for any and all comments.

Russ

Upvotes: 0

Views: 1147

Answers (1)

Pulak Agrawal
Pulak Agrawal

Reputation: 2481

Try nesting

<classpath>
<pathelement location="C:\**\**.jar"/>
</classpath> 

Inside the taskdef, e.g.

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
        <pathelement location="C:\myfolder\ant-contrib-1.0b3.jar"/>
    </classpath> 
</taskdef> 

Ideally it should pick up from ant/lib, but specifying pathelement forces it to look in the given path.

Upvotes: 6

Related Questions