0

Given that:

.
├── build.gradle
├── com.example.moduleone
│  ├── build.gradle
│  └── src
│  └── main
│  └── java
│  ├── com
│  │  └── example
│  │  └── botany
│  │  ├── fruit
│  │  │  └── Tomato.java
│  │  └── package-info.java
│  └── module-info.java
├── com.example.moduletwo
│  ├── build.gradle
│  └── src
│  └── main
│  └── java
│  ├── com
│  │  └── example
│  │  └── food
│  │  ├── package-info.java
│  │  └── vegetable
│  │  └── Potato.java
│  └── module-info.java
├── gradle
│  └── wrapper
│  ├── gradle-wrapper.jar
│  └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib
│  └── markista.docagrams.jar
└── settings.gradle

I would assume that with the correct Javadoc command options, the following Javadoc comment will be rendered as a link to the Tomato class in com.example.moduleone:

/// [com.example.moduleone/com.example.botany.fruit.Tomato] is a reference to a class 
 

Instead, when I run javadoc, I get an error:

javadoc -d build/doc/com.example.moduletwo \
 --module-path com.example.moduleone/build/classes/java/main:com.example.moduletwo/build/classes/java/main \
 --source-path com.example.moduleone/src/main/java:com.example.moduletwo/src/main/java \
 -subpackages com.example.food.vegetable:com.example.botany.fruit \
 -link ../com.example.moduleone --add-modules com.example.moduleone \
 com.example.moduletwo/src/main/java/module-info.java \
 com.example.moduletwo/src/main/java/com/example/food/vegetable/Potato.java \
 com.example.moduletwo/src/main/java/com/example/food/package-info.java
Loading source file com.example.moduletwo/src/main/java/module-info.java...
Loading source file com.example.moduletwo/src/main/java/com/example/food/vegetable/Potato.java...
Loading source file com.example.moduletwo/src/main/java/com/example/food/package-info.java...
Loading source files for package com.example.food.vegetable...
Loading source files for package com.example.botany.fruit...
Constructing Javadoc information...
Creating destination directory: "build/doc/com.example.moduletwo/"
error: Error reading file: build/doc/com.example.moduletwo/../com.example.moduleone/element-list
Building index for all the packages and classes...
Standard Doclet version 24.0.1
Building tree for all the packages and classes...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/com/example/food/vegetable/Potato.html...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/com/example/botany/fruit/Tomato.html...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/com/example/botany/fruit/package-summary.html...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/com/example/botany/fruit/package-tree.html...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/com/example/food/vegetable/package-summary.html...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/com/example/food/vegetable/package-tree.html...
Generating build/doc/com.example.moduletwo/com.example.moduletwo/module-summary.html...
Generating build/doc/com.example.moduletwo/overview-tree.html...
Generating build/doc/com.example.moduletwo/allclasses-index.html...
Building index for all classes...
Generating build/doc/com.example.moduletwo/allpackages-index.html...
Generating build/doc/com.example.moduletwo/index-all.html...
Generating build/doc/com.example.moduletwo/search.html...
Generating build/doc/com.example.moduletwo/index.html...
Generating build/doc/com.example.moduletwo/help-doc.html...
1 error

The full path to the Tomato class and its source is:

com.example.moduleone/build/classes/java/main/com/example/botany/fruit/Tomato.class
com.example.moduleone/src/main/java/com/example/botany/fruit/Tomato.java

module-info.java from com.example.moduleone:

/// Example module
module com.example.moduleone {
 exports com.example.botany.fruit;
}

module-info.java from com.example.moduletwo:

/// Example module
module com.example.moduletwo {
 exports com.example.food.vegetable;
}

Git repo with reproducible problem:

https://github.com/sandydunlop/javadoc-reference-not-found

asked Sep 4 at 19:43
1
  • Can you try adding requires com.example.moduleone; or at least requires static com.example.moduleone; to the module-info.java of com.example.moduletwo? Commented Sep 4 at 21:24

1 Answer 1

-1

Maybe you need to run Javadoc on moduleone before moduletwo can pick it up?

answered Sep 4 at 20:14
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, I think something was wrong with my gradle build file. I've re-rwitten it and the problem seems to have gone away now. I suspect as you said it wasn't generating moduleone's elements-list before it was trying to build moduletwo's docs.
@SandyDunlop Testing things out, it does look like that's the problem. But if subproject B depends on subproject A, then running ./gradlew javadoc should cause subproject A to build its Javadoc first, letting the Javadoc of subproject B succeed. However, I'm seeing that the links are file URIs, so I don't know that the links will work if you publish your Javadoc (even if just via javadoc.io). You may want to consider creating "aggregate" Javadocs. Since you're apparently using JPMS, that should involve specifying the --module-source-path and --module arguments.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.