Ant构建文件和库

问题描述:

我尝试了试图包含依赖库的众多方法。Ant构建文件和库

我的项目依赖于:

appframework-1.03.jar,摆动worker.jar和摆动布局罐子

这是我的构建文件:

  <?xml version="1.0" encoding="UTF-8"?> 
      <project name="IvleFileSync" default="dist" basedir="."> 
      <description> 
       simple example build file 
      </description> 
      <!-- set global properties for this build --> 
      <property name="src" location="src"/> 
      <property name="build" location="build"/> 
      <property name="dist" location="dist"/> 

     <path id="files-classpath"> 
      <fileset dir="/usr/lib" > 
       <include name="*.jar"/> 
      </fileset> 
     </path> 

      <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}"/> 
      <classpath> 
       <path refid="files-classpath" /> 
       <path location="/usr/lib/swing-layout-1.0.3.jar"/> 
       <path location="/usr/lib/swing-worker-1.1.jar"/> 
       <path location="/usr/lib/appframework-1.03.jar"/> 
      </classpath> 

      </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/IvleFileSync-${DSTAMP}.jar" basedir="${build}"/> 
      </target> 

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

但是我不能够编译源代码

它总是抛出包org.jdesktop.application不存在的错误。

我已经把我所有的罐子在 “/ usr/lib目录”

您定义的类路径之前关闭javac任务:

<javac srcdir="${src}" destdir="${build}"/> 
<classpath>... 
              ^-- javac is closed here. 

<javac srcdir="${src}" destdir="${build}"> 
    <classpath>...</classpath> 
</javac> 

还有的将其更换无需将两个jar添加到类路径中。您使用<path refid=加入一次,然后再列出罐子。

+0

是啊多数民众赞成真棒!谢谢!!! – redDragonzz