ANT:复制与同一文件的多个文件集的内容,按照优先顺序 [英] ANT: Copy contents of multiple filesets with same files in order of priority

查看:310
本文介绍了ANT:复制与同一文件的多个文件集的内容,按照优先顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个Web应用程序这需要从多个位置的类文件。这些位置可以包含相同的类文件。我需要能够使一些地方在整个复制类时比别人优先指定优先级。

I'm trying to build a web application which takes it's class files from multiple locations. These locations can contain the same class files. I need to be able to specify a priority so that some locations take priority over others when copying the classes across.

我们有哪些构建WAR文件单独ant脚本。此版本在任何变更类热插拔,而我发展。所以这个版本要快。

We have separate ant scripts which build the WAR file. This build is to hotswap in any changed classes whilst I am developing. So this build must be quick.

例如,我的两个班的位置是:

For example, my two class locations are:


  • / bin中

  • /编译/班

欲从这两个目录类被复制到:
/ WEB / WEB-INF / classes中

I want classes from both these directories to be copied to: /web/WEB-INF/classes

但是,如果这两个位置都包含相同的类文件,例如:

However, if both these locations contain the same class file, eg:


  • /bin/com/ben/Test.class

  • /build/classes/com/ben/Test.class

我想在/ Bin文件总是优先。

I want files in /bin to always take priority.

因此​​,在例如:


  • 文件:/bin/com/ben/Test.class,将被复制

  • 文件:/build/classes/com/ben/Test.class将被忽略

我现在的剧本是这样的:

My current script looks like this:

<sync todir="${deploy}/WEB-INF/classes" verbose="true">
    <fileset dir="bin"/>
    <fileset dir="build/classes"/>
</sync>

这工作,但每个脚本运行时,悬空的文件将被删除。我也不能确定是否在这里的任何优先保证。

This works, but each time the script is run, dangling files are removed. I'm also not sure if any priority here is guaranteed.

任何援助将AP preciated。

Any assistance would be appreciated.

推荐答案

通过晃来晃去的文件被删除,你的意思是这是已经在你的文件$ {部署} / WEB-INF / classes中?目录

By dangling files being removed, do you mean files which are already in your "${deploy}/WEB-INF/classes" directory?

同步将清除现有文件的目标目录,如果你不希望这样的事情发生,我会建议使用复制来代替。

Sync will clear existing files in the target directory, if you don't want that to happen, I would recomend using copy instead.

对于具有更高优先级的文件夹,你可以只复制多次,覆盖现有文件。

As for having a folder with a higher priority, you could just copy multiple times and overwrite existing files.

  <copy todir="${deploy}/WEB-INF/classes" verbose="true">
    <fileset dir="build/classes"/>
  </copy>

  <copy todir="${deploy}/WEB-INF/classes" verbose="true"  overwrite="true">
    <fileset dir="bin"/>
  </copy>

现在,的Test.class将从构建/班,然后从箱子的Test.class覆盖复制。

Now, test.class will be copied from build/classes then overwritten by test.class from bin.

这篇关于ANT:复制与同一文件的多个文件集的内容,按照优先顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆