I’m doing some tests with Spring 2.0.8. I’ve the following problem, all the source code is downloaded with the “spring” artifact, but is not attached by mvn eclipse:eclipse to the other artifacts, for instance for “spring-aop” artifact, I can’t access source from Eclipse, despite the aop package is present in spring-2.0.8-sources.jar.
<properties>
<org.springframework.version>2.0.8</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
</dependencies>
If I add the spring-2.0.8-sources.jar manually to spring-aop in Java Build Path, then I can navigate the source code from Eclipse, but I was wondering how to tell Maven to do that, since every time I add or change a library, I’d have to repeat the attach source operation.
UPDATE: My original fear of having the configuration overwritten proved wrong. Both m2eclipse and “mvn eclipse:eclipse” don’t overwrite manual changes to the configuration. I am still interested to know if it’s possible to tell Maven to attach sources from another dependency. I’ve also a Nexus installation, if that can help.
As @Will Iverson says, recent m2eclipse plugins can download sources automatically, either ahead-of-time, or on-demand. The m2eclipse has been able to do this for quite a long time.
If this is not working:
~/.m2/settings.xmlto see if you are using a maven proxy repository,If you are using m2eclipse, you should need to use “mvn eclipse:eclipse”. Instead you just import the maven project using (for example) File > Import > Maven > Existing Maven Project.
I don’t think this will destroy your existing hand-created project settings … assuming that you haven’t accidentally checked them into SCM or something.
If you are concerned about the possibility of losing settings, make a backup copy of your workspace; e.g.
cp -r ...ortar cf ...Maven allows you to import direct from SCM in one step. That’s surely more convenient than
mvn eclipse:eclipse… and it gives you the benefits of the m2eclipse plugin.Ah. I see.
I don’t think there’s much you (or m2eclipse) can do about that. That’s arguably a bug in the Spring 2.0.x POM files or in the dependent POM files. Certainly, later versions of Spring (2.5.x and 3.0.x) don’t have that problem.