在新的Ant构建文件中指定类路径时,我遇到了一些问题:

<path id="classpath">
 <fileset dir="${extdirs}">
   <include name="**/*.jar"/>
 </fileset>
</path>


我明白了:

BUILD FAILED
/home/amira/workspace/srd/clients/ill/impressions/ILLBLI2/build.xml:46: The following error occurred while executing this line:
/home/amira/workspace/srd/clients/ill/impressions/ILLBLI2/build.xml:12:
/home/amira/workspace/extdirs/common:/home/amira/workspace/extdirs/vaadin:
/home/amira/workspace/extdirs/remap:/home/amira/workspace/extdirs/axis2:/home/amira/workspace/extdirs/axis1 does not exist.


我尝试了这个:

 <pathelement path="${extdirs}"/>


但是问题仍然存在。这是输出:

BUILD FAILED
 /home/amira/workspace/srd/clients/ill/impressions/ILLBLI2/build.xml:46: The following error occurred while executing this line:
/home/amira/workspace/srd/clients/ill/impressions/ILLBLI2/build.xml:12: taskdef class net.sf.jasperreports.ant.JRAntCompileTask cannot be found
using the classloader AntClassLoader[/home/amira/workspace/extdirs/common:
/home/amira/workspace/extdirs/vaadin:/home/amira/workspace/extdirs/remap:
/home/amira/workspace/extdirs/axis2:/home/amira/workspace/extdirs/axis1]

Total time: 0 seconds
make: *** [compile.stamp] Error 1


这是我的EXTDIRS变量的内容:


  回声$ {EXTDIRS}
  / home / amira / workspace / extdirs / common:/ home / amira / workspace / extdirs / vaadin:/ home / amira / workspace / extdirs / remap:/ home / amira / workspace / extdirs / axis2:/ home / amira / workspace / extdirs / axis1

最佳答案

正如Ravi Thapliyal所说,fileset仅适用于单个目录,而您想使用multirootfileset。不幸的是,这个目录需要用逗号分隔的一组目录,因此难度更大。

<pathconvert property="extdirs-comma-separated"
             dirsep=",">
  <path path="${extdirs}"/>
</pathconvert>
<path id="classpath">
  <multirootfileset basedirs="${extdirs-comma-separated}">
    <include name="**/*.jar"/>
  </multirootfileset>
</path>


应该管用。

10-08 13:18