2011-09-27 28 views
1

如何在我的build.xml中添加外部罐子。 我在運行build.xml時遇到了編譯錯誤。某些jar文件丟失了,我可以將它們添加到我的build.xml文件中。如何在我的build.xml中添加外部罐子

我的build.xml看起來像這樣

<project name="HUDSONSTATUSWS" default="dist" basedir="."> 
    <description> 
     Web Services build file 
    </description> 
    <!-- set global properties for this build --> 
    <property name="src" location="src"/> 
    <property name="build" location="build"/> 
    <property name="dist" location="dist"/> 
    <property name="webcontent" location="WebContent"/> 

    <target name="init"> 
    <!-- Create the time stamp --> 
    <tstamp/> 
    <!-- Create the build directory structure used by compile --> 
    <mkdir dir="${build}"/> 
    </target> 

    <target name="compile" depends="init" 
    description="compile the source " > 
    <!-- Compile the java code from ${src} into ${build} --> 
    <javac srcdir="${src}" destdir="${build}"/> 
    </target> 

    <target name="dist" depends="compile" 
    description="generate the distribution" > 

    <!-- Create the distribution directory --> 
    <mkdir dir="${dist}/lib"/> 

    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> 
    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/> 
    </target> 

    <target name="war" depends="compile" 
    description="generate the distribution war" > 

    <!-- Create the war distribution directory --> 
    <mkdir dir="${dist}/war"/> 

    <!-- Follow standard WAR structure --> 
    <copydir dest="${dist}/war/build/WEB-INF/" src="${webcontent}/WEB-INF/" /> 
    <copydir dest="${dist}/war/build/WEB-INF/classes/" src="${build}" /> 

    <jar jarfile="${dist}/war/HelloWorld-${DSTAMP}.war" basedir="${dist}/war/build/"/> 
    </target> 

    <target name="clean" 
    description="clean up" > 

    <!-- Delete the ${build} and ${dist} directory trees --> 
    <delete dir="${build}"/> 
    <delete dir="${dist}"/> 
    </target> 
</project> 

回答

3

你只需要指定類路徑javac,使用classpathclasspathref屬性,或嵌套classpath元素。詳細請參照http://ant.apache.org/manual/Tasks/javac.html。螞蟻文檔編寫得很好,詳盡無遺,並且有很多例子。它在那裏被閱讀。