Search code examples
javamavenjavadocmaven-plugin

Library javadocs generated by maven-javadoc-plugin does not work when linked on Eclipse


UPDATE1: It is not just parameter names, eclipse does not display any javadoc information at all. When you hover over a class nothing is displayed.

UPDATE2: My eclipse version is 4.2.0.

I'm using Eclipse and I would like to attach a library's javadocs to my project so that when I implement an interface and choose the option Add unimplemented methods the methods parameter names show up correctly instead of arg0, arg1, etc.

Problem is:

  • When I generate the javadocs through eclipse (Project > Generate Javadocs...) and link it to my project it works, in other words, I see the correct method parameter names.

  • When I generate the javadocs through maven-javadoc-plugin and link it to my project it does not work, in other words, I see arg0, arg1, etc.

Perhaps I'm not configuring my maven-javadoc-plugin correctly? Below the configuration from my pom.xml:

  <plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.8</version>
    <executions>
      <execution>
        <id>attach-javadocs</id>
        <goals>
          <goal>jar</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Any help will be appreciated. Not seeing the parameter names is very bad.


Solution

  • That has to do with this eclipse bug that was only fixed in version 4.3. Basically eclipse stops processing a javadoc html file on the following line:

    <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
    

    because it is expecting the charset in the content attribute like below:

     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    

    I don't think there is a way to tell the maven javadoc plugin to change this meta tag, but you can run an ANT task below from maven to fix all your html files:

    <replace dir="target/apidocs">
        <include name="**/*.html"/>
        <replacetoken><![CDATA[<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">]]></replacetoken>
        <replacevalue><![CDATA[<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">]]></replacevalue>
    </replace>