2012-03-28 105 views
3

我有一个Ant复制任务(由Jenkins构建调用的Maven脚本中定义),看起来是正确的,但不能正确复制。任务被定义为蚂蚁复制任务忽略文件

<copy todir="./Virgo/config" overwrite="true" verbose="true"> 
    <fileset dir="${config.folder}"> 
     <include name="*.properties, *.xml" /> 
    </fileset> 
</copy> 

当我运行的任务,我可以看到正确的目录中指定,但副本任务不会选择任何文件。源目录和目标目录都存在,并且我没有收到任何错误。我所看到的是

14:52:40 [INFO] Executing tasks 
14:52:40 [DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false) 
14:52:40 [antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found. 
14:52:40  [echo] Copying files from ../com.x.y.z.container.build/config... 
14:52:40 fileset: Setup scanner in dir C:\Jenkins\workspace\container-build\com.x.y.z.container.build\config with patternSet{ includes: [*.properties, *.xml] excludes: [] } 
14:52:40 [INFO] Executed tasks 

我试着将文件添加到源目录,使源文件比目标的那些更新,即使除去在目标目录中的文件。令我困扰的是,即使路径正确,fileset似乎也不匹配任何文件。有没有人见过这种行为?

回答

4

从在Ant手册PatternSet部分:http://ant.apache.org/manual/Types/patternset.html

注意,虽然包括,但不包括属性接受用逗号或空格分隔的多个元件,嵌套<include><exclude>元素期望他们的名字属性保留一个单一模式。

您可以将您的脚本更改为类似

<copy todir="./Virgo/config" overwrite="true" verbose="true"> 
    <fileset dir="${config.folder}"> 
     <include name="*.properties" /> 
     <include name="*.xml" /> 
    </fileset> 
</copy> 
+0

咦,这很有趣,我会尝试,但我用我原来的语法在另一个项目和它的工作就好了,所以我想,不是吗。但是你的建议奏效了! – TMN 2012-03-28 14:38:10

+0

我很高兴它帮助! – 2012-03-28 14:45:09