hawkeye
hawkeye

Reputation: 35692

Can I add LOCAL source jars to maven 2 build without installing them so they can be referenced in eclipse?

Note that this is source jars - not compiled jars.

Assuming I have the following:

<dependency>
    <groupId>org.swinglabs</groupId>
    <artifactId>swingx</artifactId>
    <version>0.9.2</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/swingx-0.9.3.jar</systemPath>
</dependency>

How do I add my source jars so they can be referenced in eclipse? (I know I can right-click and add to the jar as source - but I wanted a maven import to do this automatically)

Upvotes: 2

Views: 601

Answers (2)

nwinkler
nwinkler

Reputation: 54427

If you're using the m2e Eclipse plugin, there's an option to download sources for all dependencies:

  • Right-click the project
  • Maven > Download Sources

If you're not using m2e, you can download the sources from command line using

mvn dependency:sources

To get them into Eclipse, you can use

mvn eclipse:eclipse -DdownloadSources=true

The easiest way to handle this is through m2e though. I strongly recommend to install it, as it will simplify all other Maven handling from within Eclipse.

If the sources are not available in a public repository, you can either

Out of the two, the first one (local Maven repository/proxy) is recommended.

Upvotes: 1

Nishant
Nishant

Reputation: 55856

Never tried but this should work

          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                </configuration>
            </plugin>

this would also do

 mvn -Declipse.downloadSources=true eclipse:eclipse

see this http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html#downloadSources

Upvotes: 0

Related Questions