1

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?

taetaetae
  • 141
  • 1
  • 6

1 Answers1

1

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

ursa
  • 4,404
  • 1
  • 24
  • 38
  • Thanks for the advice. In the module you gave as an example (some.group.id2:artifactId2), what should we do? – taetaetae Mar 16 '23 at 12:54
  • this is just a reference to the dependency you want to see in generated docs. in your case it's module B. – ursa Mar 16 '23 at 16:23
  • I've posted a separate question in https://stackoverflow.com/questions/75758892/how-can-we-include-javadocs-in-a-javamodule-deployment , but I'm also curious about the pom configuration for module B. What should be the configuration for module B? – taetaetae Mar 16 '23 at 16:28