How can I teach Eclipse with m2eclipse to include all source .jar in my local Maven repository in the source path when looking up library source files while debugging?
Eclipse Source Folders vs Packages
In Eclipse, within a project, when and why is it advantageous to create multiple source folders, instead of having multiple packages within the default source folder (src). How do source folders behav
How to tell Maven to include the jar dependency, not the subproject source directory in Eclipse?
I use Apache Maven to manage my Java libs (jar) and some of projects that use the libs. For convinience, I use mvn eclipse:eclipse to generate Eclipse project files which can be imported into Eclipse
Eclipse not picking up Maven attached source on debug
I’ve downloaded the source for all the maven jars in my buildpath using Maven->Download Sources and mvn eclipse:eclipse -DdownloadSources=true, which worked! Yay! .When I open up the build path I c
How to make eclipse pick customized source dir in maven environment?
Here is my project in window explorer: Here is when I import it as Existing Maven Project: Here is the build path: You can see that the source directory is not picked by maven/eclipse by default; m
Change source path in eclipse android project
Is it possible to change the source path in an eclipse android project (let’s say to src/main/java)?
Eclipse link to external source path
I have Java project that uses a JAR from another Eclipse project (open source from apache). For debug I need access to the source. I have no idea where to point the source path. Everything I tried fai
Include source folder to classpath in Eclipse
Eclipse complains if I add source folder as a class folder in Java Build Path / Library. I need this for GWT that requires sources to be in the classpath. One solution is to manually add source folder
Eclipse doesn’t remember source lookup path
For some reason Eclipse doesn’t remember source lookup path for some java projects, and every time during debugging (after redeploying) I need to press Edit source lookup path button and add current
Should “Library path” point to the source files of packages?
Should Library path point to the source files of packages? Delphi 7 documentation says yes. But other people say no: The Library path should lead to compiled files (.dcp, .dcu) and (if needed) re
Eclipse Maven debug – source not found
I am trying to debug a JUnit test case within a Maven project in Eclipse on my local machine and I am getting a Source not found error on my own test class. I went through all the other similar thre
Go to Window->Preferences->Maven->Installations and ensure that Maven is configured to use your Maven installation rather than the embedder.
If it is not configured to do so, Select Add… and browse to the root of your Eclipse install, and OK the selection.
M2eclipse will then read your settings file, discover your local repository, and automatically attach the sources available in the local repository.
If m2eclipse is pointing at your local repository, you should be able to right-click and select Maven->Download Sources, or enable the preferences to download them automatically. If the sources are already present, they should simply be attached. See this answer for details and pretty screenshots.
If after following those steps sources are still not being attached, it suggests that there is something wrong with your Maven installation. You could attempt to update the m2eclipse plugin to the latest to see if it resolves the problem.
You should enabled the Download Artifact Sources preference.
For existing artifacts you can use the Download sources action:
I was having this exact same problem– I used the Maven Source Plugin to deploy the source to our repo, and when I included that project in a separate one, try as I might, it wouldn’t include the source on the Eclipse build path. I had done this before for a previous job and I knew it was possible to have the source included on the buildpath so that Eclipse will automatically link the source in the integrated debugger simply by clicking “Download Sources” as described in the other answers.
Here is what I had (which was not working for me). I had gotten this snippet of code from the maven-source-plugin’s webpage:
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions>
This would package the source in a separate JAR and upload it to our repo, but it wouldn’t automatically attach to the Eclipse debugger. Eventually, I found that I needed a <configuration><attach>true</attach></configuration> snippet included, like so:
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <attach>true</attach> </configuration>
After this, the source automatically attaches to the Eclipse debugger by right-clicking on the project in Package Explorer and doing “Maven > Download Sources”.
I hope this solves your problem.
Keep in mind that depending on your m2eclipse version you might be affected by this problem. The problem breaks source code lookup when debugging plugins.
I am also encountering the m2eclipse bug described by Anatoli. It’s still unresolved and it seems to me that it’s the cause for the questioner’s problem as well.
First of all download the jar sources. In package explorer, Maven dependencies, find your desired jar, right click on it, Maven, Download Sources.
The downloaded source jar is in your home, .m2 folder, repository and then navigate through the package name until you get the xxx-sources.jar.
Afterwards debug your maven project. In debug perspective, debug view, right click on your project, edit Source lookup, Add…, External Archive and select the downloaded source jar.