2

I have two modules, A and B, and A depends on B. They are completely separate, and B is deployed and used in an internal repository.

You want to use the maven-javadoc-plugin for documentation in A, but you also want to include the contents of B's dependent modules. For example, you might have something like this

RespostDTO testMethod(int a) { // blabla } 

Assuming we have the above method in A's module, RespostDTO is B's module code. In this case, we want to see the JavaDoc corresponding to RespostDTO in the documentation created in A. How can we do this?

What should I do for A and B modules?

1 Answer 1

2

You can explicitly add dependencies into javadoc generation:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <configuration>
        <sourcepath>${basedir}/src/main/java</sourcepath>
        <includeDependencySources>true</includeDependencySources>
        <dependencySourceIncludes>
            <dependencySourceInclude>some.group.id1:*</dependencySourceInclude>
            <dependencySourceInclude>some.group.id2:artifactId2</dependencySourceInclude>
        </dependencySourceIncludes>
    </configuration>
</plugin>

Source: https://maven.apache.org/plugins/maven-javadoc-plugin/examples/aggregate-dependency-sources.html#fine-tuning-included-dependencies

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the advice. In the module you gave as an example (some.group.id2:artifactId2), what should we do?
this is just a reference to the dependency you want to see in generated docs. in your case it's module B.
I've posted a separate question in stackoverflow.com/questions/75758892/… , but I'm also curious about the pom configuration for module B. What should be the configuration for module B?

Your Answer

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.