views:

6301

answers:

6

I use Eclipse, Maven, and Java in my development. I use Maven to download dependencies (jar files and javadoc when available) and Maven's eclipse plug-in to generate the .project and .classpath files for Eclipse. When the dependency downloaded does not have attached javadoc I manually add a link for the javadoc in the .classpath file so that I can see the javadoc for the dependency in Eclipse. Then when I run Maven's eclipse plugin to regenerate the .classpath file it of course wipes out that change.

Is there a way to configure Maven's eclipse plug-in to automatically add classpath attributes for javadoc when running Maven's eclipse plug-in?

I'm only interested in answers where the javadoc and/or sources are not provided for the dependency in the maven repository, which is the case most often for me. Using downloadSources and/or downloadJavadocs properties won't help this problem.

A: 

Would having the sources for the dependency help? You can tell the eclipse plugin to download those (and refer to them in the .classpath) with -DdownloadSources=true

matt b
+3  A: 

From the Maven Eclipse Plugin FAQ

The following example shows how to do this in the command-line:

mvn eclipse:eclipse -DdownloadSources=true  -DdownloadJavadocs=true

or in your pom.xml:

<project>
  [...]
  <build>
    [...]
    <plugins>
      [...]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <downloadSources>true</downloadSources>
          <downloadJavadocs>true</downloadJavadocs>
        </configuration>
      </plugin>
      [...]
    </plugins>
    [...]
  </build>
  [...]
</project>
ddimitrov
+5  A: 

You might consider just avoiding this problem completely by installing the javadoc jar into your local repository manually using the install-file goal and passing in the -Dclassifier=javadoc option. Once you do that the .classpath that mvn generates should be correct.

If you use a remote repo as a proxy to central you could also deploy the javadocs to that repo and then everyone else who uses that proxy will now get the javadocs automatically as well.

Mike Deck
+2  A: 

I tried all of the above and didn't get eclipse to automatically download and integrate the sources (since the packages required were already in the local m2 cache), but then you can issue an "mvn dependency:sources" so that maven downloads the sources, and then "mvn eclipse:eclipse" once again, and there you should have the sources readily setup in eclipse.

A: 

Using downloadSources and/or downloadJavadocs properties won't help this problem.

You all did not read what the his problem is. He doesn't want to use DdownloadSources or DownloadJavadocs! This here is another sad example for unnecessary web polution. READ THE WHOLE REQUEST CAREFULLY KIDS BEFORE WRITING USELESS ANSWERS THAT HAVE BEEN CLEARLY NOT ASKED FOR!!!

A: 

you crazy or what?

foo