gpt4 book ai didi

java - 如何避免父pom受到maven依赖?

转载 作者:太空宇宙 更新时间:2023-11-04 13:38:15 25 4
gpt4 key购买 nike

我的项目“XYZ”需要一个依赖项 jar,例如“A.jar”。

这个 A.jar 有一个父 pom“B.pom”(不是 jar),但是这个父 pom 文件不存在于存储库中,因为它在 A.jar 发布期间没有上传。

现在,当我构建 XYZ 时,它会尝试下载父级“B.pom”以及依赖项“A.jar”。但它失败了。有没有办法排除我的依赖项“A.jar”的父pom?我正在使用 Maven 3。

谢谢罗布

最佳答案

您可以在pluginManagement部分定义父pom中的所有插件

<pluginManagement>
<plugins>
...
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeTypes>tar.bz2</includeTypes>
<outputDirectory>${project.basedir}/target/dependencies</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</pluginManagement>

在父 pom 和子 pom 中之后,您可以控制此插件的执行阶段。如果将其粘贴到父 pom 中,请不要忘记选项 <inherited>false</inherited> ,其禁用子pom中的执行继承。

<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>

关于java - 如何避免父pom受到maven依赖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31480928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com