Search code examples
javadoc

Can multiple javadoc commands output to the same directory hierarchy?


I have multiple targets, which I'll call Foo and Bar, in my build file. Assume that Foo is built first. Each target consists of tasks to run javac, jar, and javadoc.

I would like for both javadoc commands to use the same destination directory; however,Bar's javadoc command produces a package-list file that overwrite's Foo's package-list. Additionally, I would like for Bar's javadoc to be able to link to javadoc generated for Foo, but it can only do so if there is a package-list it can read -- which would be at the same location I want it to write.

The reason I don't create a separate Javadoc target is that I would like to be able to build the javadoc for Foo, whether or not Bar compiles, and vice versa.

(How) can I have multiple javadoc commands write to the same base directory?


Solution

  • I don't think there is a good way to do this - there is not only the package-list, but also a number of other files which will regenerated (differently) by both javadoc processes:

    • constant-values.html
    • allclasses-frame.html
    • allclasses-noframe.html
    • deprecated-list.html
    • index-all.html (or per-letter index files)
    • overview-frame.html
    • overview-summary.html
    • overview-tree.html
    • serialized-form.html

    These are possible alternatives:

    • Generate separate outputs, but link them to each other (using the -link or -linkoffline option).

    • Generate a common output using the last version of the other project that was known to compile. Use your version control system for this.

    • Occassionally generate a big output with both (i.e. from stable versions).

      Then regenerate only the part for your project (into a new directory), and then copy it (without the files in the top level directory, i.e. overview and the frameset files) over the big output. The index, tree, and class lists in the top-level frameset will not be up-to date, but how often do these change anyway?

    If you want to invest lots of time, you could modify the third option to merge the new top-level files into the existing ones. Good luck.