【问题标题】:Maven: How to download the parent jar to the custom location?Maven:如何将父 jar 下载到自定义位置?
【发布时间】:2016-01-23 05:32:55
【问题描述】:

这是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>

如何将父jar下载到自定义位置?

【问题讨论】:

标签: java maven pom.xml parent-pom


【解决方案1】:

relativePath 只会在该位置查找 pom,如果找不到,它将在存储库中查找。它实际上不会将 pom 下载到该位置。如果您只想构建您的项目,只需确保父 pom 在存储库中可用。

如果您要在找到 pom 后实际下载它,请尝试使用 Maven 依赖插件,将其添加到您的 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>

然后在命令行中:

mvn dependency:get

注意工件和目标是在插件配置中指定的。

如果您不想修改 pom,可以尝试:

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

【讨论】:

  • 是否有任何命令可以自动下载父 jar 而无需过多编辑 pom 文件?
  • 检查这个stackoverflow.com/questions/34701900/… 它会自动下载所有依赖项。同样明智的是,不提及具体的工件名称,我们可以下载所有父 jar 吗??
猜你喜欢
  • 2016-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-22
  • 2012-07-15
相关资源
最近更新 更多