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?
-
Did you ever find an answer that worked for you? – Cuga Jan 29 '10 at 17:34
-
@Cuga: No, I did not. Seems to be the same for you. – desolat Feb 01 '10 at 08:11
-
1I had the same problem -- see my answer, I hope it fixes this for you. – Cuga Feb 01 '10 at 15:27
-
This solution worked for me: http://stackoverflow.com/questions/5780758/maven-always-download-sources-and-javadocs – Håvard Geithus Mar 26 '14 at 15:25
6 Answers
You should enabled the Download Artifact Sources preference.
removed dead ImageShack link
For existing artifacts you can use the Download sources action:
removed dead ImageShack link

- 9,814
- 10
- 45
- 73

- 67,031
- 36
- 206
- 278
-
1@Robert, the OP seems to be implying that the source jars are already in the local repository. If this is the case, setting download sources will result in a second copy of the sources being downloaded to the embedder's local repository, rather than that specified by the Maven install. – Rich Seller Sep 24 '09 at 08:11
-
1The source packages are downloaded, they are just not on the source lookup path when debugging. – desolat Sep 24 '09 at 09:15
-
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.

- 17,668
- 31
- 111
- 166
-
I copied the plugin config into my pom.xml. I also clean up the repository, and then mvn install. However, I am still not able to get debugger to attach my maven dependency libraries, such as spring-core, during debugging automatically. Can you provide even more detail? – Oscar Chan May 03 '10 at 22:04
-
Did you try right-clicking on the project in Package Explorer and doing "Maven > Download Sources"? – Cuga May 04 '10 at 12:42
-
I had to manually select the sources jar as suggested by @felipe-fernandez – lrkwz Dec 04 '12 at 09:34
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.

- 311
- 1
- 7
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.

- 1
- 1

- 83,208
- 23
- 172
- 177
-
I already use an external Maven installation. But source packages are not recognized and added to the source path. Where exactly do I find the source lookup path configuration for a project in Eclipse? – desolat Sep 24 '09 at 08:11
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.
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.