Discussion:
Maven javadoc plugin's aggregate-jar goal, multi-module project, and code generation
Robert Patrick
2016-01-14 04:54:00 UTC
Permalink
I am beating my head against the wall on this and surely I am just being stupid so hopefully someone will take pity on me and point me in the right direction.



I am trying to add Javadoc generation into my normal build process for my multi-module project. It all works fine if I run "mvn install" on the project followed by "mvn javadoc:aggregate-jar" but I would really like to be able to generate the javadocs jar as part of the normal build so that it:



- Gets built by default (without having to remember to run the extra command)

- Sets attached to the build so that the install plugin installs it



I put something like the following in the top-level POM (the module names have been changed to protect the innocent.):



<modules>
<module>mod1</module>
<module>mod2</module>
<module>mod3</module>
<module>mod4</module>
<module>mod5</module>
<module>mod6</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>generate-javadoc</id>
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>



Unfortunately, this runs the aggregate-jar goal first, before building the modules. Since Java code in the modules reference classes generated by the module build, the build generates tons of warnings from the Javadoc plugin about not finding the generated classes (which makes sense since they don't exist yet) like this:



[WARNING] import com.mycompany.mod4.resources.MyResourceBundle;

[WARNING] ^

[WARNING] C:\myproject\mod4\src\main\java\com\mycompany\mod4\MyApplication.java:24: error: package com.mycompany.mod4.resources does not exist



Is there really no way to do this with code generation?



Thanks,

Robert
Sarath Shasikumar
2016-01-14 05:04:40 UTC
Permalink
To execute plugin during certain phase, add <phase> to <execution>. Plugin
should be fired:
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase> <------ HERE
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>

Regards
Sarath Shasikumar
Systems Engineer
Tata Consultancy Services
Cell:- +91 97 46 136153
Mailto: ***@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Consulting
____________________________________________




From: Robert Patrick <***@oracle.com>
To: ***@maven.apache.org
Date: 01/14/2016 10:24 AM
Subject: Maven javadoc plugin's aggregate-jar goal, multi-module
project, and code generation



I am beating my head against the wall on this and surely I am just being
stupid so hopefully someone will take pity on me and point me in the right
direction.



I am trying to add Javadoc generation into my normal build process for my
multi-module project. It all works fine if I run "mvn install" on the
project followed by "mvn javadoc:aggregate-jar" but I would really like to
be able to generate the javadocs jar as part of the normal build so that
it:



- Gets built by default (without having to remember to run the
extra command)

- Sets attached to the build so that the install plugin installs it



I put something like the following in the top-level POM (the module names
have been changed to protect the innocent.):



<modules>
<module>mod1</module>
<module>mod2</module>
<module>mod3</module>
<module>mod4</module>
<module>mod5</module>
<module>mod6</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>generate-javadoc</id>
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>



Unfortunately, this runs the aggregate-jar goal first, before building the
modules. Since Java code in the modules reference classes generated by
the module build, the build generates tons of warnings from the Javadoc
plugin about not finding the generated classes (which makes sense since
they don't exist yet) like this:



[WARNING] import com.mycompany.mod4.resources.MyResourceBundle;

[WARNING] ^

[WARNING]
C:\myproject\mod4\src\main\java\com\mycompany\mod4\MyApplication.java:24:
error: package com.mycompany.mod4.resources does not exist



Is there really no way to do this with code generation?



Thanks,

Robert



=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
Robert Patrick
2016-01-14 05:36:06 UTC
Permalink
Yeah, but that won't help since the code is not all in a single module. By default, the aggregate-jar goal docs claim it is bound to the package phase and all of my source in the submodules are generated in the generate-sources phase.

Now that I analyze the output more carefully, it appears that the aggregate-jar goal is running the aggregate goal during the generate-sources phase and somehow causing the builds of the modules in parallel (even though I didn't tell it to do so). The 58 warnings are all from mod4, mod5, and mod6 (the last 3 submodules in the modules list)--even though mod1, mod2, and mod3 also use the exact same code generation and referencing techniques. So this makes me think that there is a bug in the parallel execution logic.

-----Original Message-----
From: Sarath Shasikumar [mailto:***@tcs.com]
Sent: Wednesday, January 13, 2016 11:05 PM
To: Maven Users List
Cc: Robert Patrick
Subject: Re: Maven javadoc plugin's aggregate-jar goal, multi-module project, and code generation

To execute plugin during certain phase, add <phase> to <execution>. Plugin should be fired:
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase> <------ HERE
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>

Regards
Sarath Shasikumar
Systems Engineer
Tata Consultancy Services
Cell:- +91 97 46 136153
Mailto: ***@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Consulting
____________________________________________




From: Robert Patrick <***@oracle.com>
To: ***@maven.apache.org
Date: 01/14/2016 10:24 AM
Subject: Maven javadoc plugin's aggregate-jar goal, multi-module
project, and code generation



I am beating my head against the wall on this and surely I am just being stupid so hopefully someone will take pity on me and point me in the right direction.



I am trying to add Javadoc generation into my normal build process for my
multi-module project. It all works fine if I run "mvn install" on the
project followed by "mvn javadoc:aggregate-jar" but I would really like to
be able to generate the javadocs jar as part of the normal build so that
it:



- Gets built by default (without having to remember to run the
extra command)

- Sets attached to the build so that the install plugin installs it



I put something like the following in the top-level POM (the module names
have been changed to protect the innocent.):



<modules>
<module>mod1</module>
<module>mod2</module>
<module>mod3</module>
<module>mod4</module>
<module>mod5</module>
<module>mod6</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>generate-javadoc</id>
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>



Unfortunately, this runs the aggregate-jar goal first, before building the
modules. Since Java code in the modules reference classes generated by
the module build, the build generates tons of warnings from the Javadoc
plugin about not finding the generated classes (which makes sense since
they don't exist yet) like this:



[WARNING] import com.mycompany.mod4.resources.MyResourceBundle;

[WARNING] ^

[WARNING]
C:\myproject\mod4\src\main\java\com\mycompany\mod4\MyApplication.java:24:
error: package com.mycompany.mod4.resources does not exist



Is there really no way to do this with code generation?



Thanks,

Robert



=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you



---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@maven.apache.org
For additional commands, e-mail: users-***@maven.apache.org

Sarath Shasikumar
2016-01-14 05:07:26 UTC
Permalink
To execute plugin during certain phase, add <phase> to <execution>. Plugin

should be fired:
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase> <------ HERE
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>

Regards
Sarath Shasikumar
Systems Engineer
Tata Consultancy Services
Cell:- +91 97 46 136153
Mailto: ***@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Consulting
____________________________________________




From: Robert Patrick <***@oracle.com>
To: ***@maven.apache.org
Date: 01/14/2016 10:24 AM
Subject: Maven javadoc plugin's aggregate-jar goal, multi-module
project, and code generation



I am beating my head against the wall on this and surely I am just being
stupid so hopefully someone will take pity on me and point me in the right
direction.



I am trying to add Javadoc generation into my normal build process for my
multi-module project. It all works fine if I run "mvn install" on the
project followed by "mvn javadoc:aggregate-jar" but I would really like to
be able to generate the javadocs jar as part of the normal build so that
it:



- Gets built by default (without having to remember to run the
extra command)

- Sets attached to the build so that the install plugin installs it



I put something like the following in the top-level POM (the module names
have been changed to protect the innocent.):



<modules>
<module>mod1</module>
<module>mod2</module>
<module>mod3</module>
<module>mod4</module>
<module>mod5</module>
<module>mod6</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>generate-javadoc</id>
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>



Unfortunately, this runs the aggregate-jar goal first, before building the
modules. Since Java code in the modules reference classes generated by
the module build, the build generates tons of warnings from the Javadoc
plugin about not finding the generated classes (which makes sense since
they don't exist yet) like this:



[WARNING] import com.mycompany.mod4.resources.MyResourceBundle;

[WARNING] ^

[WARNING]
C:\myproject\mod4\src\main\java\com\mycompany\mod4\MyApplication.java:24:
error: package com.mycompany.mod4.resources does not exist



Is there really no way to do this with code generation?



Thanks,

Robert



=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
Loading...