开发者

can you do this seemingly simple Ant copy task without using ant-contrib's foreach?

I have a source d开发者_运维问答irectory with a bunch of plugins. Each plugin has its own lib directory. I want the contents of each of those lib directories to be merged into a single lib directory within my build. In theory you'd do something like this:

<copy todir="build/web/lib">
    <fileset dir="web/plugins/*/lib/" includes="**/*" />
</copy>

However, Ant chokes when the dir attribute includes a wildcard. Is ant-contrib the only alternative, or can you make this work with vanilla ant?

Choke message is build.xml:28: [...]/web/plugins/*/lib does not exist.


The dir= attribute of a fileset doesn't take a wildcard - hence the error you see. You need to specify a single directory, in this case web/plugins, and use a slightly different wildcard for the includes:

<copy todir="build/web/lib">
    <fileset dir="web/plugins" includes="*/lib/**/*" />
</copy>

If you need to alter the paths as you copy, you can use a mapper, for example the flattenmapper will give you file names with all leading directory information stripped off.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜