问题描述
我的项目“ XYZ”需要一个依赖项jar,例如“ A.jar”。
此A.jar的父pom为“ B.pom”(不是jar),但是此父pom文件在存储库中不存在,因为它在A.jar发行期间未上载。
现在,当我构建XYZ时,它将尝试下载父级“ B.pom”以及依赖项“ A.jar”。 它失败了。 有什么办法可以排除我的依赖项“ A.jar”的父pom吗? 我正在使用Maven 3。
谢谢罗布
1楼
您可以在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>
在父子poms中之后,您可以控制此插件的执行阶段。如果将其粘贴到父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>