ant 任务将属性文件复制到它们在 java 构建目录中的相应位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/775279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ant task to copy properties file to their corresponding place in the java build dir
提问by Jason S
OK, I'm stumped.
好吧,我难住了。
I have a Java tree that looks like a fairly typical Eclipse Java build:
我有一个 Java 树,它看起来像一个相当典型的 Eclipse Java 构建:
myproject
src
com
example
test
// Java files in com.example.test here
bin
com
example
test
// Compiled class files will go here
Now I have a MyClass.propertiesfile in myproject/src/com/example/testalong with the source Java files. How can I write an appropriate ant task to copy all the changed .properties files in the source tree, to their corresponding places in the build (myproject/bin) tree?
现在我有一个MyClass.properties文件myproject/src/com/example/test和源 Java 文件。如何编写适当的 ant 任务来将源树中所有更改的 .properties 文件复制到它们在构建 ( myproject/bin) 树中的相应位置?
(The easier half of this is to do the actual copy; the harder half of this I'm guessing is checking for dependencies)
(其中较简单的一半是进行实际复制;我猜这其中较难的一半是检查依赖项)
回答by Chris Thornhill
How about:
怎么样:
<copy todir="myproject/bin">
<fileset dir="myproject/src" includes="**/*.properties"/>
</copy>
回答by Gary Kephart
From the Ant manual about the task:
从关于任务的 Ant 手册中:
Copies a file or resource collection to a new file or directory. By default, files are only copied if the source file is newer than the destination file, or when the destination file does not exist. However, you can explicitly overwrite files with the overwrite attribute.
将文件或资源集合复制到新文件或目录。默认情况下,仅当源文件比目标文件新或目标文件不存在时才复制文件。但是,您可以使用 overwrite 属性显式覆盖文件。

