Search code examples
antbuild-processjavadoc

Port javadoc to ant task: How implement "[@files]" option?


I'm trying to add javadoc to my ant build process do not really have an idea how to "convert" one option of javadoc into the ant task "< javadoc >". Here the javadoc usage:

usage: javadoc [options] [packagenames] [sourcefiles] [@files]

This is what I already tried:

    <javadoc sourcefiles="build/sourcefiles.txt">
    </javadoc>

And I want to have the option [@files] in my ant task, but could not find a proper way to do so...may you have any idea?

Thanks in advance...


Solution

  • The simplest (primitive) way would be to use the arg subelement to supply more command line arguments.

    <javadoc>
      <arg value="@build/sourcefiles.txt" />
    </javadoc>
    

    But I suppose that this will not work this way, since the javadoc task wants at least the required attributes to be given.

    To take a list of files from a file, the filelist resource collection together with the loadfile task may help:

    <loadfile property="sourcefiles-list"
              srcFile="build/sourcefiles.txt"
              encoding="US-ASCII" />
    <javadoc destdir="...">
      <sourcefiles>
        <filelist files="${sourcefiles-list}"/>
      </sourcefiles>
    </javadoc>
    

    Actually, the packagelist attribute might be what you want:

    <javadoc destdir="..." sourcepath="..."
             packageList="build/sourcefiles.txt">
    </javadoc>
    

    Try this first (I'm not sure if it also accepts file names there).