views:

1984

answers:

2

OK, I'm stumped.

I have a Java tree that looks like a fairly typical Eclipse Java build:

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.properties file in myproject/src/com/example/test along 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?

(The easier half of this is to do the actual copy; the harder half of this I'm guessing is checking for dependencies)

+3  A: 

From the Ant manual about the task:

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.

Gary Kephart
ok, so that answers my checking for dependency half. What about the syntax? I can't seem to figure it out, sorry I'm pretty dense. :(
Jason S
+6  A: 

How about:

<copy todir="myproject/bin">
   <fileset dir="myproject/src" includes="**/*.properties"/>
</copy>
Chris Thornhill
that's it?! thanks! where does the manual for the copy task talk about the **/ preserving paths for the destination dir?
Jason S
It doesn't explicitly talk about that, but I suppose you could arrive at that conclusion this way: When matching files, the path from the base dir leading up to that file is captured as well. Knowing that, look at the description of the "flatten" attribute on the copy task. The behavior described when flatten=true implies that paths will be preserved when it is false.
Chris Thornhill