javajavadocjava-modulemodule-path

how to generate javadoc for multiple modules


I'm trying to create javadoc (jdk11) for multiple modules in a single document.

I tried to do it like this.

The file/directory structure is:

workspace
    doc
    maths
        src
            main
                java
                    net.virtualpsyclab.maths
                        net
                            virtualpsyclab
                                maths
                                    lib
                                        *.java
                    module-info.java
    genutils
        src
            main
                java
                    net.virtualpsyclab.genutilsm
                        net
                            virtualpsyclab
                                genutilsm
                                    *.java
                    module-info.java
module-info.java
jdocOptions.txt
files.lst

jdocOptions.txt contains:

-d doc
--module-source-path .;genutils\src\main\java\net.virtualpsyclab.genutilsm;maths\src\main\java\net.virtualpsyclab.maths
--module workspace,net.virtualpsyclab.genutilsm,net.virtualpsyclab.maths
-verbose
-overview overview.html

and files.lst lists all the *.java files.

The three module-info.java files contain:

workspace\module-info.java
module workspace{
    requires net.virtualpsyclab.genutilsm;
    requires net.virtualpsyclab.maths;
}

workspace\genutils\src\main\java\net.virtualpsyclab.genutilsm\module-info.java
module net.virtualpsyclab.genutilsm{
    exports net.virtualpsyclab.genutilsm;
}

workspace\maths\src\main\java\net.virtualpsyclab.maths\module-info.java
module net.virtualpsyclab.maths{
    exports net.virtualpsyclab.maths.lib;
}

I want the documentation for the modules net.virtualpsyclab.genutilsm and net.virtualpsyclab.maths to appear in the directory workspace\doc and I run the command:

javadoc @jdocOptions.txt @files.lst 

from the directory workspace and I see all of the source files apparently being processed e.g. :

Loading source file c:\Users\Admin\workspace\maths\src\main\java\net.virtualpsyclab.maths\net\virtualpsyclab\maths\lib\NDieDistribution.java...
[parsing started SimpleFileObject[C:\Users\Admin\workspace\maths\src\main\java\net.virtualpsyclab.maths\net\virtualpsyclab\maths\lib\NDieDistribution.java]]
[parsing completed 0ms]

but then it all ends badly with "javadoc: error - module workspace not found."

Any help on what I've got wrong here greatly appreciated.


Solution

  • Based on the information in this question and here I have now worked out how to do this. These links explain the multi-module mode of operation for various java tools. Multi-module mode is triggered by inclusion of option --module-source-path. The elements of the module-source-path are directories which contain module definitions. A module definition can be a directory corresponding to the module name and containing module-info.java and a directory structure corresponding to packages and source files. With this I dropped the idea of an aggregator module (delete module-info.java from my workspace directory, above) and changed the jdocOptions.txt file to read as follows:

    -d doc
    --module-source-path genutils\src\main\java\;maths\src\main\java\
    

    The crucial changes are dropping the --module option which is used in single module mode to identify the root module and shortening the paths in the --module-source-path option so that the module directory e.g. net.virtualpsyclab.maths is a sub-directory of the path rather than being part of the path.

    Now I have in workspace/doc the required documentation for my two modules!