基于 Nant 文件集的模式
我有一个 SVN externals 文件夹,其中包含许多名为 *Plugin
的文件夹,然后在每个文件夹中都有一个 modules
文件夹和一个 binaries
文件夹。
我的问题是,在我的构建任务中,我想将 **/*
从模块复制到我的项目中的某个位置,以及任何 *.plugin.dll
从二进制文件位置到我项目中的其他位置。
所以这里是一个虚拟示例:
- DummyPlugin1
|- binaries
|- some.assembly.dll
|- some.plugin.dll
|- modules
|- some-named-folder
|- some-sub-folder
|- some.content.xml
|- some-other-sub-folder
|- yet-another-folder
|- some.more.content.jpg
- DummyPlugin2
|- binaries
|- some.other.plugin.dll
|- modules
|- another-named-folder
|- content.xml
|- image.jpg
|- yet-another-named-folder
|- some-web-page.html
所以在这个示例中我想基本上复制:
- some.plugin.dll
- some.other.plugin.dll
到给定的输出目录,然后从模块目录中我想要获取:
- some-named -folder (和所有内容)
- another-named-folder (和所有内容)
- Yet-another-named-folder (和所有内容)
并将所有内容放入另一个给定的输出目录中。
我试图这样做:
<copy todir="${dir.projects.dynamic.binaries}">
<fileset basedir="${dir.plugins}/**/binaries">
<include name="*.plugin.dll" />
</fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
<fileset basedir="${dir.plugins}/**/modules">
<include name="**/*" />
</fileset>
</copy>
但是我不断收到错误消息,告诉我文件集上的 basedir 不能包含 ** 或任何其他无效符号。关于您是否可以或不能在基于文件集的模式中使用模式,该文档似乎有点模糊,但是我假设在此错误之后我不能。
问题是,如果我这样做:
<copy todir="${dir.projects.dynamic.binaries}">
<fileset basedir="${dir.plugins}">
<include name="**/binaries/*.plugin.dll" />
</fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
<fileset basedir="${dir.plugins}">
<include name="**/modules/**/*" />
</fileset>
</copy>
但是它会复制父文件夹,即 DummyPlugin1/binaries/some.assemble.dll
、DummyPlugin2/binaries/some.other.plugin .dll
而不仅仅是我想要的 dll。与模块相同...
我知道我可以更改 basedir 以包括 DummyPlugin1/binaries、DummyPlugin2/binaries,但我不知道其中会有多少文件夹或它们的名称是什么,而无需不断更改构建脚本,所以我宁愿保持它的动态,这样它就会为我取出其中的任何插件和模块,而不是我必须为可能存在或不存在的每个插件文件夹制作一个副本。
那么有什么办法可以让我在这里鱼与熊掌兼得呢?
I have an SVN externals folder which contains many folders called *Plugin
then within each of these folders there is a modules
folder and a binaries
folder.
The problem for me is, within my build task I want to copy **/*
from modules to a location within my project, as well as any *.plugin.dll
from the binaries location to somewhere else in my project.
So here is a dummy example:
- DummyPlugin1
|- binaries
|- some.assembly.dll
|- some.plugin.dll
|- modules
|- some-named-folder
|- some-sub-folder
|- some.content.xml
|- some-other-sub-folder
|- yet-another-folder
|- some.more.content.jpg
- DummyPlugin2
|- binaries
|- some.other.plugin.dll
|- modules
|- another-named-folder
|- content.xml
|- image.jpg
|- yet-another-named-folder
|- some-web-page.html
So in this example I would want to basically copy:
- some.plugin.dll
- some.other.plugin.dll
To a given output directory, then from the modules directory I would want to take:
- some-named-folder (and all content)
- another-named-folder (and all content)
- yet-another-named-folder (and all content)
and put all of that in another given output directory.
I was trying to do this:
<copy todir="${dir.projects.dynamic.binaries}">
<fileset basedir="${dir.plugins}/**/binaries">
<include name="*.plugin.dll" />
</fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
<fileset basedir="${dir.plugins}/**/modules">
<include name="**/*" />
</fileset>
</copy>
However I keep getting an error telling me that basedir on fileset cannot contain ** or any other invalid symbols. The documentation seems a bit vague as to if you can or cannot use patterns in your fileset basedir or not, however I am assuming after this error that I cannot.
The problem is that if I was to do this way instead:
<copy todir="${dir.projects.dynamic.binaries}">
<fileset basedir="${dir.plugins}">
<include name="**/binaries/*.plugin.dll" />
</fileset>
</copy>
<copy todir="${dir.projects.dynamic.modules}">
<fileset basedir="${dir.plugins}">
<include name="**/modules/**/*" />
</fileset>
</copy>
However it copies the parent folders, i.e DummyPlugin1/binaries/some.assembly.dll
, DummyPlugin2/binaries/some.other.plugin.dll
rather than just the dll which I want. Same with the modules...
I know I could change the basedir to include DummyPlugin1/binaries, DummyPlugin2/binaries but I do not know how many folders will be in there or what their names will be without constantly altering the build script, so I would rather keep it dynamic so it will just pull out whatever plugins and modules are in there for me, rather than me having to make a copy for EACH plugin folder that may or may not be in there.
So is there any way for me to have my cake and eat it here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
basedir
必须是单个目录,但您应该能够使用flatten
选项,它将所有输入文件放入单个输出目录中(基本上忽略路径)。再次阅读您的问题后:您可以尝试一下吗?
basedir
has to be a single directory, but you should be able to accomplish what you want using theflatten
option, which puts all input files into a single output directory (ignoring the paths, basically).After reading your question again: can you try this?
答案已包含在您的问题中:使用
循环:The answer was already included in your question: use a
<foreach>
loop: