i am sure m2eclipse maven plugin for eclipse - the other way around - can do that. you can configure it to download both the source files and javadoc automatically for you.
this is achieved by going into
window > preferences > maven and checking the "download artifact sources" and "download artifact javadoc" options.
i had a similar problem, and the solution that worked best for me was to include the source in the same jar as the compiled code (so a given directory in the jar would include both
foo.class). eclipse automatically associates the source with the compiled code, and automatically provides the javadoc from the source. obviously, that's only helpful if you control the artifact.
after setting the properties either at project level or user properties level, please do a maven -> update project (force update). it downloads the sources
a small addition to the answer, if your project is not a maven project still you can get the source code of the jars, by using this plugin provided in eclipse java source attacher
i've added the pom configuration to the maven-eclipse plugin to download source and javadocs, but i figure/hope that will happen for new dependencies, not existing ones.
for existing dependencies, i browsed in package explorer down to the "maven dependencies" and right-clicked on commons-lang-2.5.jar, selected maven | download sources and... nothing appeared to happen (no progress bar or indication that it was doing anything). it did, however, download as i'm able to jump to source in commons-lang now.
overthink suggested using the setup in the pom:
... other stuff ...
first i thought this still won't attach the javadoc and sources (as i tried unsuccessfully with that -ddownloadsources option before).
but surprise - the .classpath file is getting its sources and javadoc attached when using the pom variant!
for indigo (and probably helios) the checkboxes mentioned above are located here:
window -> preferences -> maven
changing pom for maven-eclipse-plugin to include source/javadoc just apply for new dependencies being added to pom. if we need to apply for existing dependencies, we must run mvn dependency:sources. i checked this.
checking download source/javadoc in eclipse-maven preference, sometimes is not enough. in the event maven failed to download them for some reason (a network blackout?), maven creates some *.lastupdated files, then will never download again. my empirical solution was to delete the artifact directory from .m2/repository, and restart the eclipse workspace with download source/javadoc checked and update projects at startup checked as well. after the workspace has been restarted, maybe some projects can be marked in error, while eclipse progress is downloading, then any error will be cleared. maybe this procedure is not so "scientific", but for me did succeded.
there is also a similiar question that answers this and includes example pom settings.
in my version of eclipse helios with m2eclipse there is no
window --> maven --> download artifact sources (select check)
under window is only "new window", "new editor" "open perspective" etc.
if you right click on your project, then chose
maven--> download sources
nothing happens. no sources get downloaded, no pom files get updated, no window pops up asking which sources.
doing mvn xxx outside of eclipse is dangerous - some commands dont work with m2ecilpse - i did that once and lost the entire project, had to reinstall eclipse and start from scratch.
im still looking for a way to get ecilpse and maven to find and use the source of external jars like servlet-api.
windows->pref..->maven but it was not working out. hence i created a new class path with command mvn eclipse:eclipse -ddownloadsources=true and refreshed the workspace once. voila.. sources were attached.
source jar's entry is available in class path. hence new build solved the problem...
if you are using meclipse do
window --> maven --> download artifact sources (select check)
(if you still get attach source window, then click on attach file button and close the attach source window. the next time you try to see the source it will open the correct source)
if the source jars are in the local repository and you are using eclipses maven support the sources are getting automatically attached. you can run
mvn dependency:sources to download all source jars for a given project. not sure how to do the same with the documentation though.
right click on
project -> maven -> download sources
i prefer not to put source/javadoc download settings into the project
pom.xml file as i feel these are user preferences, not project properties. instead, i place them in a profile in my
<?xml version="1.0" encoding="utf-8"?>
the other answers on this work, but if you want to avoid having to remember command line arguments, you can also just add to the downloadsources and downloadjavadocs config to the maven-eclipse-plugin section of your pom.xml:
... other stuff ...
mvn eclipse:eclipse -ddownloadsources=true
mvn eclipse:eclipse -ddownloadjavadocs=true
or you can add both flags, as spencer k points out.
=true portion is not required, so you can use
mvn eclipse:eclipse -ddownloadsources -ddownloadjavadocs
- Get source jar files attached to Eclipse for Maven-managed dependencies
- Where is source for JAR files downloaded by Eclipse Maven plugin?
- Can the Gradle Eclipse Plugin attach source jar files to local jar dependencies
- Maven dynamic web project in eclipse deploys invalid jar files for dependent project(s)
- Eclipse does not search for files in Maven downloaded jar files
- Maven eclipse project using editable source code for the maven dependencies
- How to get the source jar file for eclipse jdk plugins?
- How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
- Why does Eclipse maven produce huge .cfs files for no reason?
- 'Open Declaration' in Eclipse navigates to class files instead of to source files for Android Libraries
- Debugging jar file with source code attached in eclipse
- Eclipse not picking up Maven attached source on debug
- Automatically Creating Manifest File with Eclipse for JAR Files
- How do I get maven managed dependencies copied into war\web-inf\lib so I can run my GWT 2.0 app in debug mode within Eclipse?
- What JAR files are needed for Eclipse to use JSTL so it ultimately works on GAE/J?
- Eclipse : How to remove the attached Source which was added to a Jar
- Maven does not add dependency jar files to project when importing to eclipse
- Search files by text in Maven Dependencies folder in Eclipse
- Using Different Properties Files for Runnable Jars, Maven Eclipse
- Eclipse not linking private member names for library with attached source
- How can I get Eclipse to store .class files in a folder outside the Project folder where I store the .java source files?
- Eclipse does not show source code of maven dependencies in debug view
- eclipse search for resource including jar files
- How to add jar files for spring in Eclipse IDE project folder
- Using eclipse and maven 2, how to get dependancy for sqljdbc4?
- How can I add imported jar files to web-inf/lib in eclipse for my build?
- How to make the runnable jar file for a maven eclipse project with hibernate configuration
- How to tell Eclipse not include project reference, instead get JAR for custom dependency in local repo
- In Eclipse with m2e, how to get "Quick Javadoc" (F2) to display for Maven dependencies?
- Adding External jar files in Eclipse for EAR Project
More Query from same tag
- Saving multiple files in Eclipse using Ctrl+s causes "The file cannot be edited"
- External jar files are not detected when compiled using cmd.?
- autoComplete suggestion doesn't work in eclipse java
- eclipse: build path with other projects, how to prevent test src from being included?
- Menu items in Eclipse Juno do not work - unresponsive
- Importing third Party Eclipse Plugin Code
- How to call methods that is in an external library?
- DBMS_RANDOM doesn't seem to work
- Eclipse apparently picks up all but one projects from Git repository
- Develop a Scala/Lift Web App using Eclipse and Tomcat
- Cannot get my java project to build org.apache.maven.lifecycle.LifecycleExecutionException:
- Build failure in a simple Maven project with wildfly (wildfly:deploy)
- Activity does not work on clicking
- Eclipse - Error: Could not find or load main class stacks
- issues with apache tomcat 8startup in eclipse mars
- Customizing AntRunner output
- How can I debug doInBackground code of an AsyncTask
- eclipse keyboard language change key not working
- Text fields are not displayed on the barchart created using jfreechart in Eclipse RCP
- Integrating appcompat with LibGDX's Gradle Projects in Eclipse
- NetBeans "link with editor" feature
- xtext domainmodel project doesn't recognize JVM types
- Git in Eclipse not recognizing new files
- How to Enable CSV Logger in Eclipse STEM
- Java Annotations in eclipse Tooltip?
- How to add additional source code to an imported existing makefile-project with eclipse?
- "Get Key Failed: Given final block not properly padded" when I try loading .p12 certificate in a Java project
- Eclipse Content Assist function arguments auto-insert
- Run PyDev project as root without running eclipse as root. (without problems)