1

This is follow up post of the In maven project How to download the library in source/binary, mentioned in the <parent> tag in POM file?

<project>
<parent>
 <groupId>org.jboss.weld</groupId>
 <artifactId>weld-api-bom</artifactId>
 <version>1.0</version>
 <relativePath>../bom/pom.xml</relativePath>
</parent>

 <modelVersion>4.0.0</modelVersion>
 <artifactId>my-module</artifactId>

 <dependencies>
 <dependency>
  <groupId>javax.el</groupId>
  <artifactId>el-api</artifactId>
  <optional>true</optional>
 </dependency>
</dependencies>

How to download the parent jar to the custom location?

Community
  • 1
  • 1
Dinesh Ravi
  • 1,209
  • 1
  • 17
  • 35
  • This would be so easy with gradle! Section 34.3 https://docs.gradle.org/current/userguide/publishing_maven.html – JimLohse Jan 23 '16 at 06:54
  • 1
    Can we download all the dependent and parent jars using gradle? – Dinesh Ravi Jan 23 '16 at 06:57
  • Yeah very briefly in a file called build.gradle you use `apply plugin: 'maven'` and there's a section where you declare access to MavelLocal and MavenCentral like this: `repositories { mavenLocal(); mavenCentral(); }` Then for example if you want to include Spark it's a one-liner, click on the Spark tab here: http://mvnrepository.com/artifact/org.apache.spark/spark-core_2.10/1.6.0 – JimLohse Jan 23 '16 at 07:03

1 Answers1

1

relativePath will only look for the pom in that location, and if not found, it will look it up in the repository. It won't actually download the pom to that location. If all you want is to build your project, just make sure the parent pom is available in the repository.

If what you are looking for is to actually download the pom after it was found, try using the Maven Dependency Plugin, adding this to your pom:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <version>2.10</version>
      <configuration>
        <artifact>org.jboss.weld:weld-api-bom:1.0:pom</artifact>
        <destination>../bom/pom.xml</destination>
      </configuration>
      <executions>
        <execution>
        <goals>
          <goal>get</goal>
        </goals>
      </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Then in the command line:

mvn dependency:get

Note the artifact and the destination are specified in the plugin configuration.

If you don't want to modify the pom you could try:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -Dartifact=org.jboss.weld:weld-api-bom:1.0:pom -Ddest=../bom/pom.xml
ecarlos
  • 209
  • 1
  • 6
  • Is there any command to automate the download of parent jar without much editing the pom file? – Dinesh Ravi Jan 23 '16 at 06:55
  • Check this http://stackoverflow.com/questions/34701900/how-to-download-the-souce-of-jars-to-custom-location-in-maven?noredirect=1#comment57244107_34701900 it downloads all the dependent automatically. Like wise, without mentioning the specific artifact name can we download all the parent jars ?? – Dinesh Ravi Jan 25 '16 at 04:25