开发者

create a fileset of all files matching a pattern, excluding files with a specific sibling file

I would like to create a fileset of files matching a specific pattern, but exclude from this set any files which have a specific other file in the same directory.

E.g., I would like a fileset which matches all ./*/fi开发者_StackOverflow社区le.xml files, like:

<fileset dir="${some.dir}" includes="*/file.xml" />

... but I want to exclude any file.xml files which are in the same director as an ignore.this file.

So if the dir structure is:

foo/file.xml
bar/file.xml
bar/ignore.this

... the the file.xml in foo will be selected, but bar will not.


You can use a fileset with a present selector with a mapper:

<fileset dir="${some.dir}" includes="*/file.xml">
    <present targetdir="${some.dir}" present="srconly">
        <mapper type="regexp" from="^(.*)/.*" to="\1/ignore.this" />
    </present>
</fileset>

That is, include only files called file.xml where there is no corresponding file in the same directory called ignore.this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜