34

I have a multimodule java project built with Maven to which I want to generate javadocs with javadoc:aggregate. The project structure looks like:

parent
├─lomboklib
└─other

I am also using Project Lombok to generate some methods in the project. I have successfully configured it to work with single modules by first running delombok with the Lombok maven plugin. For single modules (lomboklib), this will generate source code in

target/generated-sources/delombok

which is then processed by maven-javadoc-plugin and the javadoc tool. This was originally solved in This SO question.

How can I configure the javadoc:aggregate report to also use the generated sources?

I've put up a sandbox of the problem with all the module definitions in Github. Ideally, I should be able to run

mvn clean compile javadoc:aggregate

In the parent project, and have the whole thing compile and get javadocs for the entire project.

Community
  • 1
  • 1
Eero Aaltonen
  • 3,571
  • 1
  • 21
  • 38
  • Great question. Same issue on a project with dozens of modules which all use lombok. You'd hope there was some way to overide the subdir that javadoc:aggregate looks in as it recurses through the models. We are running with the hacky solution from @Ben M. which is working. – Sodved May 27 '20 at 03:51

3 Answers3

3

I created a workaround build configuration that will create aggregated javadocs from generated sources, although the call sequence has two steps:

mvn package
mvn -N pre-site

The build configuration is now published in Github. The current version only supports a project tree of depth one, but can of course be modified. It works by gathering the dependencies under the parents target directory and then running the included Ant script.

Finally, if running under Jenkins, the mvn -N pre-site can be invoked in the same job through Execute shell post step. Publishing the javadocs in our version of Jenkins required using the post-build action "Use publishers from another project".

Eero Aaltonen
  • 3,571
  • 1
  • 21
  • 38
2

I downloaded the example project from Github to recreate your problem and discovered that it was because the lombok-maven-plugin was configured unnecessarily at the top-level pom -- it is only needed for the module that contains lombok code. By simply removing that configuration, javadoc:aggregate behaves as expected.

AWhitford
  • 2,510
  • 1
  • 21
  • 27
2

I'm having this same problem, and I've been able to work around it by referencing the source paths directly from the parent project.

Try this configuration for your parent pom's maven-javadoc-plugin.

<configuration>
    <sourcepath>
        lomboklib/target/generated-sources/delombok;
        other/target/generated-sources/delombok
    </sourcepath>
</configuration>

It's really not ideal. It feels like a bit of a hack.

Ben M.
  • 1,860
  • 1
  • 12
  • 23