Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant task to copy properties file to their corresponding place in the java build dir

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)

like image 729
Jason S Avatar asked Apr 22 '09 00:04

Jason S


People also ask

Which of the following task is used for downloading file from web in Ant?

resource collections are used to select groups of URLs to download. If the collection contains more than one resource, the dest attribute must point to a directory if it exists or a directory will be created if it doesn't exist.

What is Basedir in build xml?

The 'basedir' is the base directory from which any relative directories used within the Ant build file are referenced from. If this is omitted the parent directory of the build file will be used.


2 Answers

How about:

<copy todir="myproject/bin">
   <fileset dir="myproject/src" includes="**/*.properties"/>
</copy>
like image 172
Chris Thornhill Avatar answered Sep 22 '22 12:09

Chris Thornhill


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.

like image 41
Gary Kephart Avatar answered Sep 19 '22 12:09

Gary Kephart