Reputation: 10981
I'm totally new with Ant
, and I don't know how classpath
works in Ant
. I have wrote a Java
class to do some scripting for me, and I wanted to deploy it as a task
in Ant
. The class uses commons-codec-1.2.jar
as an external library, in other to do some Unicode
and MD5
tasks for me. I've posted my build.xml
file.
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="TcZip" basedir="." default="jar">
<property name="src.dir" value="src" />
<property name="classes.dir" value="classes" />
<property name="library.dir" value="library" />
<path id="external.classpath">
<pathelement location="${library.dir}/commons-codec-1.2.jar" />
</path>
<target name="clean" description="Delete all generated files">
<delete dir="classes" />
<delete file="TcZip.jar" />
</target>
<target name="compile" description="Compiles the task">
<mkdir dir="${classes.dir}" />
<javac srcdir="src" destdir="classes" />
<classpath>
<path refid="external.classpath" />
</classpath>
</target>
<target name="jar" description="JARs the Task" depends="compile">
<jar destfile="TcZip.jar" basedir="classes" />
</target>
<target name="use" description="Use the task" depends="jar">
<taskdef name="tczip" classname="ZipComparision" classpath="${ant.project.name}.jar" />
<tczip />
</target>
</project>
In my task
directory, I have :
+task
- build.xml
- classes
- library
- src
library
and classes
contain the commons-codec-1.2.jar
file. However, as seen in the build.xml
file I have added a <property>
tag for the library
.
When I execute ant compile
I get:
compile:
[javac] C:\workspace\task\build.xml:19: warning: 'includeantr
untime' was not set, defaulting to build.sysclasspath=last; set to false for rep
eatable builds
[javac] Compiling 3 source files to C:\workspace\task\classes
[javac] C:\workspace\task\src\Tczip.java:18: error: package o
rg.apache.commons.codec.binary does not exist
[javac] import org.apache.commons.codec.binary.Hex;
[javac] ^
[javac] C:\workspace\task\src\Tczip.java:190: error: cannot f
ind symbol
[javac] mdEnc = new String( Hex.encodeHex( digest ));
[javac] ^
[javac] symbol: variable Hex
[javac] location: class Tczip
[javac] C:\workspace\task\src\Tczip.java:254: error: cannot f
ind symbol
[javac] mdEnc = new String( Hex.encodeHex( digest ));
[javac] ^
[javac] symbol: variable Hex
[javac] location: class Tczip
[javac] 3 errors
BUILD FAILED
C:\workspace\task\build.xml:19: Compile failed; see the compiler
error output for details.
Could someone please help me with that? Thank you
Upvotes: 1
Views: 4018