1

这是In maven 项目 How to download the library in source/binary, 在 POM 文件中的 <parent> 标记中提到的后续帖子?

<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 下载到自定义位置?

4

1 回答 1

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
于 2016-01-23T06:43:38.490 回答