17

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.

                    <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <inherited>false</inherited>
                    <executions>
                        <execution>
                            <id>generate-javadoc</id>
                            <phase>package</phase>
                            <goals>
                                <goal>aggregate</goal>
                            </goals>
                            <configuration>
                                <aggregate>true</aggregate>
                                <links>
                                    <link>http://java.sun.com/javase/6/docs/api</link>
                                    <link>http://java.sun.com/javaee/5/docs/api</link>
                                </links>
                                <maxmemory>512</maxmemory>
                                <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
                                <docletArtifact>
                                    <groupId>org.umlgraph</groupId>
                                    <artifactId>doclet</artifactId>
                                    <version>5.2</version>
                                </docletArtifact>
                                <additionalparam>
                                    -inferrel -inferdep -outputencoding utf8 -hide
                                    java.* -collpackages
                                    java.util.*
                                    -qualify -postfixpackage
                                    -nodefontsize 9 -nodefontpackagesize 7
                                </additionalparam>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
2
  • try phase install instead of package for the execution Oct 10, 2011 at 19:14
  • 2
    Install phase doesn't seem to help because the parent/aggregator project is built first in the reactor order so all of its phases are run before any of the module are built. So whether its install or package it is done before the first module is built so the dependency that the javadoc has on the modules is not satisfied because they aren't built. Oct 11, 2011 at 17:32

2 Answers 2

0

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.

5
  • Thanks for the reply, although unfortunately this is not the same thing. With the config above I get a site/apidocs directory in the top level target directory with all of the modules javadoc in one place. If I do what you suggest each module builds its own javadoc but there is not top level javadoc for all of them. Oct 11, 2011 at 14:12
  • @John. I guess javadoc:javadoc does not aggregate. Perhaps javadoc:aggregate does?
    – Raghuram
    Oct 11, 2011 at 14:38
  • 1
    Thanks a lot for the response. It does, but since the top level pom runs first in the reactor order, none of the other modules are built yet and the javadoc plugin thinks they are all dependencies so it breaks saying it can't find the necessary jars. I'm not sure how aggregate would ever work given this. Is there a way to make the top level pom LAST in the reactor order? If its first I can't see why it wouldn't always break trying to find the artifacts of the modules that haven't built yet. Oct 11, 2011 at 21:08
  • 1
    @John, I meant mvn clean install javadoc:aggregate
    – Raghuram
    Oct 12, 2011 at 2:06
  • 1
    thanks again. The issue I think is that the reactor order for my builds is the top level pom first and then all of the modules. So anything I try to do in the top level pom (also the parent pom of the modules) is done before all of the modules are built. I'm now looking around for ways to switch the reactor order of that top level pom but I don't have high hopes. I'm also trying another module that depends on all the other ones and builds the javadoc but that is exceptionally lame. Ah well. Oct 12, 2011 at 13:59
-1

Is your javadoc plugin declaration in the <build> part of your pom. You should consider moving it to the <reporting> part see this link.

2
  • You cannot run arbitrary plugins during reporting. <reporting><plugins><plugin><executions> isn't even valid wrt the POM schema. Oct 31, 2019 at 15:19
  • It seems you are right. I thought it was the same behaviour for the javadoc plugin between build and report because in the doc it was written that in the case of a project report you should put it in the reporting part but it clearly doesn't work in that case because the xsd forbids it. The official doc just has the configuration part and not the execution part. My bad. Nov 4, 2019 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.