How to execute maven plugin _after_ all module builds finish

Specifically I am trying to run maven-javadoc-plugin but whenever I change the version numbers on the parent/aggregator pom and all of the children, the first time I run the build it fails because javadoc runs first and can’t find any of the new version packages from the modules because they haven’t been built yet.

I usually end up having to comment javadoc out for one build and then add it back in once the packages are available in nexus for the new version. However, this likely means that I’ve been building javadoc on one build old source jars all the time.

I’ve read suggestions of putting another module in that depends on the other ones but I don’t think i can get a module to build the javadoc for peer modules. Having it in the parent builds all of the javadoc for all of the modules, I just need it to happen later. Thanks. Here’s my javadoc plugin config.

                                    -inferrel -inferdep -outputencoding utf8 -hide
                                    java.* -collpackages
                                    -qualify -postfixpackage
                                    -nodefontsize 9 -nodefontpackagesize 7


One way to get around this problem is not to invoke javadoc plugin in the normal maven lifecycle phase; instead run it separately.

To be specific, remove <phase> tag from the above plugin definition.

Run mvn install javadoc:javadoc from parent.

This will build and install all the modules and the parent and then run javadoc on them.

Source : Link , Question Author : John Russell , Answer Author : Raghuram

Leave a Comment