<p>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.</p>

<p>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?  </p>

<p>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.</p>

[{'answer_id': 44405, 'author': 'matt b', 'author_id': 4249, 'author_profile': 'https://Stackoverflow.com/users/4249', 'pm_score': -1, 'selected': False, 'text': '<p>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 <code>-DdownloadSources=true</code></p>\n'}, {'answer_id': 97168, 'author': 'ddimitrov', 'author_id': 18187, 'author_profile': 'https://Stackoverflow.com/users/18187', 'pm_score': 5, 'selected': False, 'text': '<p>From the Maven Eclipse Plugin <a href="http://maven.apache.org/plugins/maven-eclipse-plugin/examples/attach-library-sources.html" rel="noreferrer">FAQ</a></p>\n\n<blockquote>\n  <p>The following example shows how to do\n  this in the command-line:</p>\n\n<pre><code>mvn eclipse:eclipse -DdownloadSources=true  -DdownloadJavadocs=true \n</code></pre>\n  \n  <p>or in your pom.xml:</p>\n\n<pre><code>&lt;project&gt;\n  [...]\n  &lt;build&gt;\n    [...]\n    &lt;plugins&gt;\n      [...]\n      &lt;plugin&gt;\n        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;\n        &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;\n        &lt;configuration&gt;\n          &lt;downloadSources&gt;true&lt;/downloadSources&gt;\n          &lt;downloadJavadocs&gt;true&lt;/downloadJavadocs&gt;\n        &lt;/configuration&gt;\n      &lt;/plugin&gt;\n      [...]\n    &lt;/plugins&gt;\n    [...]\n  &lt;/build&gt;\n  [...]\n&lt;/project&gt;\n</code></pre>\n</blockquote>\n'}, {'answer_id': 142968, 'author': 'Mike Deck', 'author_id': 1247, 'author_profile': 'https://Stackoverflow.com/users/1247', 'pm_score': 5, 'selected': True, 'text': '<p>You might consider just avoiding this problem completely by installing the javadoc jar into your local repository manually using the <a href="http://maven.apache.org/plugins/maven-install-plugin/usage.html" rel="noreferrer">install-file goal</a> and passing in the -Dclassifier=javadoc option.  Once you do that the .classpath that mvn generates should be correct.</p>\n\n<p>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.</p>\n'}, {'answer_id': 9176224, 'author': 'luckyphil', 'author_id': 1194632, 'author_profile': 'https://Stackoverflow.com/users/1194632', 'pm_score': 5, 'selected': False, 'text': "<p>I'm running STS 2.8.1 which is basically eclipse + spring tools; In an existing maven project, I right clicked on the project -> maven -> Download Sources and Download JavaDocs</p>\n"}, {'answer_id': 24314931, 'author': 'Philippe', 'author_id': 35274, 'author_profile': 'https://Stackoverflow.com/users/35274', 'pm_score': 5, 'selected': False, 'text': '<p>As mentioned in <a href="https://stackoverflow.com/questions/17086272/how-to-download-sources-and-javadoc-artifacts-with-maven-eclipse-plugin-from-oth">How to download sources and javadoc artifacts with Maven Eclipse plugin from other repository?</a>, you can do this:</p>\n\n<p>In Eclipse go to Windows-> Preferences-> Maven. Check the box that says "Download Artifact Javadoc." That has worked well for me.</p>\n\n<p><img src="https://i.stack.imgur.com/l65wb.jpg" alt="Maven Preferences"></p>\n'}, {'answer_id': 43304553, 'author': 'KulDeep', 'author_id': 2684384, 'author_profile': 'https://Stackoverflow.com/users/2684384', 'pm_score': 2, 'selected': False, 'text': '<p>Generally Javadocs are not primarily used as dependency . Because these are neither required at compile nor runtime. It’s just to help the developer while developing or debugging.</p>\n<p>Assuming using the java IDE Eclipse we can use the java docs as referenced. Following are the approaches we can associate the javadocs/sources with the respective jars.</p>\n<p><strong>1.    If it’s non-maven project :</strong></p>\n<p>Download the javadocs jar or zipped file, whatever available and placed it in some directory.\nRight click on the application project in the IDE Eclipse, click Properties and  choose Java Build Path then select tab Libraries under the Java  Build Path.  Now expand the jar you want to link with java docs/source.  Select the Javadoc location link and click on Edit button, a new window appears where we need to choose the javadocs jar path. Click OK and we have linked the javadoc/source with the respective jars.</p>\n<p><a href="https://i.stack.imgur.com/uqG0l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uqG0l.png" alt="enter image description here" /></a></p>\n<p><strong>2.    If it’s a maven project</strong></p>\n<p>If we are using the Maven project then  go to jar files under the Maven dependency under the project in Project Explorer view as shown below. Now right click on the jar file you want to add the Javadoc/source,  \uf0e0 choose Maven then click on Javadoc or Source you want to link with the project. Now IDE will automatically download the required javadoc/source and will link it with the respective jar in the project.</p>\n<p><a href="https://i.stack.imgur.com/2Shat.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Shat.png" alt="enter image description here" /></a></p>\n<p>You can verify this by right click on the project in the IDE and click on Java Build Path and select the Libraries tab under the Java Build Path and then expand the desired jar, here when you click the Edit button you will see the linked path of the Javadoc/Source with the respective jar as shown below in the image.</p>\n<p><a href="https://i.stack.imgur.com/WxMcR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WxMcR.png" alt="enter image description here" /></a></p>\n<p><strong>3.    If  it’s Maven project and we are setting the default behavior:</strong></p>\n<p>Eclipse will aquatically download the javadoc/source  along with the main required jar at the starting.\nBy default setting instruction to Maven to download the Javadoc/sources for all the jars linked in the project.</p>\n<p>Click Windows – preferences – select Maven and click the checkbox Download Artifact Javadoc as shown below</p>\n<p><a href="https://i.stack.imgur.com/LM9Xl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LM9Xl.png" alt="enter image description here" /></a></p>\n<p>Now click on apply and save it and  now when you create new Maven project , by default the Javadocs will get downloaded and linked with all the dependent jars in the project.<br />\nYou can verify by right click on the project and Properties and under Java Build path can see the javadocs are linked with all the jars as shown below.</p>\n<p><a href="https://i.stack.imgur.com/ZzFcX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZzFcX.png" alt="enter image description here" /></a></p>\n<p><strong>If your project is Maven project then  It’s always best to use 2nd approach  because by using this approach the IDE and Maven,  takes care of downloading the correct version of the Javadoc/source and linked it with the relative jar as well.</strong></p>\n<p><strong>Approach 3rd is bit costly because the javadoc/sources will be downloaded for-all the dependent jars, may be you are not interested for javadocs/sources for all the dependent jars.</strong></p>\n'}]
['https://Stackoverflow.com/questions/44396', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4476/']