有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

ant任务将属性文件复制到java构建目录中相应的位置

好吧,我被难住了

我有一个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

现在我在myproject/src/com/example/test中有一个MyClass.properties文件和源Java文件。如何编写一个适当的ant任务来复制所有更改的内容。是否将源树中的属性文件移动到构建(myproject/bin)树中相应的位置

(这其中较容易的一半是进行实际复制;我猜较难的一半是检查依赖项)


共 (2) 个答案

  1. # 1 楼答案

    那么:

    <copy todir="myproject/bin">
       <fileset dir="myproject/src" includes="**/*.properties"/>
    </copy>
    
  2. # 2 楼答案

    从关于任务的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.