Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven javadoc:javadoc works but javadoc:aggregate throws errors that look like compiler errors

I am trying to create an aggregate javadoc for a multi module project. The project compiles with mvn install -DskipTests (I am not running tests on my machine). When I run mvn validate javadoc:javadoc it works and compiles all of the javadoc in each modules \target\apidocs directory. Then when I run either mvn validate javadoc:javadoc javadoc:aggregate or mvn validate javadoc:aggregate fails partway through with about 1200 lines of errors. Some examples of types are:

Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:aggregate (default-cli) on project commons-superpom: An error has occurred in JavaDocs report generation:
[ERROR] Exit code: 1 - C:\workspaces\win\tfs\****\Foo.java:21: type org.springframework.context.ApplicationListener does not take parameters
[ERROR] public class Foo implements ApplicationContextAware, ApplicationListener<ContextRefreshedEvent> {
[ERROR] ^
.
.
.
C:\workspaces\win\tfs\****\test\Bar.java:52: cannot find symbol
[ERROR] symbol  : class PostInsertEvent
[ERROR] location: class com.Barclass
[ERROR] public void BarFunct(PostInsertEvent event) {
[ERROR] ^
[ERROR] C:java.lang.NullPointerException
[ERROR] at com.sun.tools.javadoc.TypeMaker.getType(TypeMaker.java:67)
[ERROR] at com.sun.tools.javadoc.TypeMaker.getType(TypeMaker.java:29)
[ERROR] at com.sun.tools.javadoc.ClassDocImpl.superclassType(ClassDocImpl.java:439)
[ERROR] at com.sun.tools.doclets.internal.toolkit.util.Util.getAllInterfaces(Util.java:386)
[ERROR] at com.sun.tools.doclets.internal.toolkit.util.Util.getAllInterfaces(Util.java:424)
[ERROR] at com.sun.tools.doclets.internal.toolkit.util.ClassTree.processType(ClassTree.java:162)
[ERROR] at com.sun.tools.doclets.internal.toolkit.util.ClassTree.buildTree(ClassTree.java:114)
[ERROR] at com.sun.tools.doclets.internal.toolkit.util.ClassTree.<init>(ClassTree.java:73)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:104)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42)
[ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143)
[ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
[ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:128)
[ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:41)
[ERROR] at com.sun.tools.javadoc.Main.main(Main.java:31)

After it crashes all that is left in the /target directory next to my parent pom.xml is 2 files 1 is javadoc-bundle-options which contains an xml file:

<?xml version="1.0" encoding="UTF-8"?>
<javadocOptions>
  <docletArtifacts>
    <docletArtifact />
  </docletArtifacts>
  <tagletArtifacts>
    <tagletArtifact />
  </tagletArtifacts>
  <excludePackageNames>
    <excludePackageName>org.foobar.*</excludePackageName>
  </excludePackageNames>
  <javadocResourcesDirectory>src/main/javadoc</javadocResourcesDirectory>
</javadocOptions>

and the second is site which contains a file called apidocs which contains 3 files javadoc.bat, options, and packages. They contain what they appear to contain a batch script to run the javadoc.exe with those options and on those packages.

The first error I copied is straight up wrong. ApplicationListener is parameterized and can take ContextRefreshedEvent per the spring documentation. PostInsertEvent is correctly imported as well in the second error. I don't know where the NullPointerException is happening.

My plugin configuration for javadoc:aggregate is as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>${maven-javadoc-plugin.version}</version>
    <executions>
            <execution>
                    <id>attach-javadocs</id>
                    <goals>
                            <goal>aggregate</goal>
                    </goals>
            </execution>
    </executions>
    <configuration>
            <excludePackageNames>org.hibernate.*;org.spring.*<-!-- ;com.***.hibernate.audit --></excludePackageNames>
            <verbose>true</verbose>
            <fork>true</fork>
            <showDeprecation>true</showDeprecation>
            <showWarnings>true</showWarnings>
            <source>${java.source.version}</source>
            <target>${java.target.version}</target>
            <compilerVersion>${java.source.version}</compilerVersion>
            <compilerArgument>-Xlint:all</compilerArgument>
            <minmemory>128m</minmemory>
            <maxmem>512m</maxmem>

            <encoding>${project.build.sourceEncoding}</encoding>

            <additionalparam>
                    -charset UTF-8 
                    -docencoding UTF-8 
                    -version 
                    -author 
                    -breakiterator 
                    -linksource 
                    -sourcetab 4 
                    -windowtitle "${project.name} ${project.version} API Reference" 
                    -doctitle "${project.name} ${project.version} API Reference" 
                    -bottom "Copyright ${project.inceptionYear}-Present ${project.organization.name}. All Rights Reserved." 
                    -link http://java.sun.com/javase/6/docs/api/
                    -link http://jsr311.java.net/nonav/releases/1.1
            </additionalparam>
    </configuration>
 </plugin>

If I exclude the commented package then the build runs fine. If however I exclude all of the files in the package and not the package then it crashes with very similar errors. I can generate the javadoc just fine in eclipse. I can stop the nullpointerexception if I edit the options file generated after a failure to use 3.3.2.GA/hibernate-core-3.3.2.GA.jar instead of hibernate-core-4.1.8.Final.jar and then run the bat file. This produces a complete aggregate javadoc site however, there are several errors relating to @Typedef in the run. Javadoc 1.7_60 and 1.6_45 both fail in the same way.

like image 502
alexddupree Avatar asked Jul 03 '14 23:07

alexddupree


People also ask

How do I fix Javadoc errors?

You need to call mvn javadoc:fix to fix main Java source files (i.e. inside src/main/java directory) or mvn javadoc:test-fix to fix test Java source files (i.e. inside src/test/java directory).

How do I disable Javadoc in Maven?

The Javadoc generation can be skipped by setting the property maven. javadoc. skip to true [1], i.e.


1 Answers

Fixed: There is a bug in the javadoc compiler both 1.6 and 1.7 where annotations that do not have a jar throw a NPE. The 1.8 javadoc compiler works however I was still getting errors as I didn't have the correct jar. I had to look through several different poms as one of my modules had a different hibernate library hard coded into it.

The final results: When I changed that library to the standard one maven couldn't compile but the javadoc:aggregate would run just fine. Switching both to the version in my module didn't work either. I ended up having to remove the module from my javadoc build using this work around. This didn't matter to much as it was an experimental module but if I had needed it I would have simply added a profile that allowed me to change the version on javadoc run.

Hope no one gets stuck on this again like I did. :)

like image 92
alexddupree Avatar answered Nov 11 '22 21:11

alexddupree