我是全新的Ant
,我不知道如何classpath
在Ant
. 我写了一个Java
类来为我编写一些脚本,我想将它部署为一个task
in Ant
. 该类commons-codec-1.2.jar
用作外部库,在其他方面为我做一些Unicode
和MD5
任务。我已经发布了我的build.xml
文件。
<?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>
在我的task
目录中,我有:
+task
- build.xml
- classes
- library
- src
library
并classes
包含该commons-codec-1.2.jar
文件。但是,如build.xml
文件中所示,我<property>
为library
. 当我执行时,ant compile
我得到:
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.
有人可以帮我吗?谢谢