Question

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?

Était-ce utile?

La solution

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top