我怎样才能从蚂蚁的参考路径排除文件? [英] How can I exclude files from a reference path in Ant?
问题描述
在一个项目,我们有几个源路径,因此我们定义了一个参考路径为他们:
In a project we have several source paths, so we defined a reference path for them:
<path id="de.his.path.srcpath">
<pathelement path="${de.his.dir.src.qis.java}"/>
<pathelement path="${de.his.dir.src.h1.java}"/>
...
</path>
使用缓建工程在&lt罚款; javac的&GT;标签:
Using the reference works fine in the <javac> tag:
<src refid="de.his.path.srcpath" />
在下一步,我们要非Java文件复制到类路径文件夹:
In the next step, we have to copy non-java files to the classpath folder:
<copy todir="${de.his.dir.bin.classes}" overwrite="true">
<fileset refid="de.his.path.srcpath">
<exclude name="**/*.java" />
</fileset>
</copy>
不幸的是,这样做的不的工作,因为REFID和嵌套元素不得混用。
Unfortunately, this does not work because "refid" and nested elements may not be mixed.
有没有一种方法,我可以得到一组在我的源路径的所有非Java文件,而不复制的源路径列表中为单个文件集?
Is there a way I can get a set of all non-java files in my source path without copying the list of source paths into individual filesets?
推荐答案
下面是一个选项。首先,使用 pathconvert 任务,使一个模式适用于产生一个文件集:
Here's an option. First, use the pathconvert task to make a pattern suitable for generating a fileset:
<pathconvert pathsep="/**/*,"
refid="de.his.path.srcpath"
property="my_fileset_pattern">
<filtermapper>
<replacestring from="${basedir}/" to="" />
</filtermapper>
</pathconvert>
接着从路径的所有文件,除了Java源代码使文件集。注意尾随通配符 / ** / *
如需要只pathconvert不列表中的通配符,而不是一个在年底需要:
Next make the fileset from all the files in the paths, except the java sources. Note the trailing wildcard /**/*
needed as pathconvert only does the wildcards within the list, not the one needed at the end:
<fileset dir="." id="my_fileset" includes="${my_fileset_pattern}/**/*" >
<exclude name="**/*.java" />
</fileset>
那么你的副本任务将是:
Then your copy task would be:
<copy todir="${de.his.dir.bin.classes}" overwrite="true" >
<fileset refid="my_fileset" />
</copy>
有关的便携性,而不是硬编码的UNIX通配符的/ ** / *
则可以考虑使用类似:
For portability, instead of hard-coding the unix wildcard /**/*
you might consider using something like:
<property name="wildcard" value="${file.separator}**${file.separator}*" />
这篇关于我怎样才能从蚂蚁的参考路径排除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!