0

I am using Maven2 to build my project. I want my build to automatically download dependency source jars when it is compiled. Dependency executable jars are downloading correctly. My dependency looks like this:

...
<dependencies>
    <dependency>
      <groupId>id.name</groupId>
      <artifactId>artifact-name</artifactId>
      <version>1403.00</version>
    </dependency>
</dependencies>
...

I do have the maven source plugin:

...
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <goal>jar</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
...
</plugins>
...

I've also tried adding this configuration to the pom under the maven-source-plugin:

<configuration>
   <downloadSources>true</downloadSources>
   <downloadJavadocs>true</downloadJavadocs>
</configuration>

What do I need to add to my pom file to make this happen?

ABC123
  • 1,037
  • 2
  • 20
  • 44
  • Duplicate of http://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository – Software Engineer Mar 04 '14 at 19:25
  • 1
    You don't need the source-plugin, just do mvn dependencies:source and any dependencies you have in your pom will be downloaded along with their source. If you're using IntelliJ, then there is a button to do this for you. – Software Engineer Mar 04 '14 at 19:27
  • This is not a duplicate question. The accepted answer to that question uses the CLI. I don't want to use the CLI. – ABC123 Mar 04 '14 at 20:05

1 Answers1

1

Add this to your POM:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.8</version>
            <executions>
                <execution>
                    <id>download-sources</id>
                    <goals>
                        <goal>sources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
Harald Wellmann
  • 12,615
  • 4
  • 41
  • 63