开发者

Javadoc creation with maven

We have created a new artifact to generate javadoc. We have 40 artifacts defined as dep开发者_如何学运维endencies. Task is to create javadoc.jar and html pages for the 40 dependency artifacts.

Whats the best approach to achieve this in maven?


This is very unusual. Javadoc works on sources, not compiled classes, whereas maven dependencies reference classes, not sources.

So to make this work you'll have to do all of this:

  • since this is a dedicated javadoc artifact, it won't have a main JAR artifact, so you'll probably want to set the packaging to POM
  • make sure all your referenced artifacts have attached sources
  • add <classifier>sources</classifier> to all your dependencies
  • unpack all dependencies to a common root folder using dependency:unpack-dependencies
  • run javadoc on that folder
  • create a jar using the maven-assembly-plugin
  • attach that jar to the build using the buildhelper plugin

On re-reading the question: I'm assuming that you want to create combined docs of all dependencies. If not, you'll need 40 separate executions each of the javadoc, assembly and buildhelper plugins. Good luck with that.


A slightly more automated approach than the answer above:

So to make this work you'll have to do all of this:

  • since this is a dedicated javadoc artifact, it won't have a main JAR artifact, so you'll probably want to set the packaging to POM
  • make sure all your referenced artifacts have attached sources
  • add <classifier>sources</classifier> to all your dependencies
  • unpack all dependencies to a common root folder using dependency:unpack-dependencies
  • Change your sources directory to where you unpacked all the dependencies
  • Use the source plugin to manage all the Javadoc generation and deployment
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜