简体   繁体   中英

hOW can i add external jars in my build.xml

hOW can i add external jars in my build.xml. i am getting compilation error while running my build.xml.some jars are missing.how can i add them in my build.xml.

my build.xml looks like this

<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>

You just need to specify the classpath for javac , using the classpath or classpathref attribute, or a nested classpath element.

See http://ant.apache.org/manual/Tasks/javac.html for details. The ant documentation is very well written, exhaustive, and full of examples. It's there to be read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM