如何在apache ant的build.xml中的classpath中加载所有支持jar

时间:2012-04-13 13:49:18

标签: ant build hudson

我为每个创建jar,war,ear文件的项目制作build.xml文件

要调用此build.xml,我已经制作了一个主build.xml

现在我在Hudson中配置了这个项目

问题是从hudson构建项目时,hudson无法将相对路径转换为绝对路径。

所以我想做一些全局声明并添加所有jar路径并在build.xml的类路径中加载所有jar路径

<fileset dir="${class.dir}" includes="**/*.jar"/>

<fileset dir="${AllJar.dir}" includes="**/*.jar"/>

1 个答案:

答案 0 :(得分:1)

关键是要定义具有一些ID的单个文件集,并定义master path with refid

从链接引用:

  

类似路径的结构可以包括对另一个路径的引用   通过嵌套的结构(路径本身就是一个资源集合)    元素:

<path id="base.path">
  <pathelement path="${classpath}"/>
  <fileset dir="lib">
    <include name="**/*.jar"/>
  </fileset>
  <pathelement location="classes"/>
</path>

<path id="tests.path" cache="true">
  <path refid="base.path"/>
  <pathelement location="testclasses"/>
</path>

在这个test.path中包含base.path,它包含$ {classpath}和lib文件夹中的所有jar。