Search code examples
antjavacpost-processing

How can I post-process files compiled using the Ant javac task?


I need the list of files that were compiled during this run. I want to feed this list to a subsequent post-processing step.

I have found an option to list (see listfiles option) the files compiled during this run, but it seems only good for displaying the list on console.

Any idea?

Edit: I am talking about incremental compiles, so taking a fileset of the build folder is not an option.

Edit: One idea seems to be custom logger but I am still looking for something simpler

Edit: Another idea is to use depend selector with FileSet before javac and somehow keep the list in memory, to be used after javac has executed


Solution

  • You simply can form a fileset about all class-files in the target-directory of the javac.

    Edit: After the clarification I have to adjust my answer. I didn't such thing yet, but I would try my luck with selectors. The modified-selector looks like the one you want - a fileset of all class-files in a directory, that have changed since the last run. Here is a code-snippet:

    <fileset dir="${build}">
       <filename name="**/*.class"/>
       <modified/>
    </fileset>
    

    It does not directly post-process the output of the javac-task, but should solve your problem.