【问题标题】:Maven Assembly plugin dependency version scopeMaven Assembly 插件依赖版本范围
【发布时间】:2016-04-17 04:49:14
【问题描述】:

我有一个使用程序集插件的 maven 项目,其中包括项目依赖项。

其中一个依赖项在 pom 中声明为:
<dependency> <groupId>com.oracle.sqlj</groupId> <artifactId>runtime12</artifactId> <version>11.1.0.0.0</version> <scope>compile</scope> </dependency>

项目的 pom 也有一个父 pom,必须包含,但我无法更改。在那里,是:
<dependency> <groupId>com.oracle.sqlj</groupId> <artifactId>runtime12</artifactId> <version>10.1.0.2.0</version> <scope>compile</scope> </dependency>

组装插件的 xml 中的依赖声明如下: <dependencySets> <dependencySet> <outputDirectory>etc/lib</outputDirectory> <useProjectArtifact>false</useProjectArtifact> <!-- INCLUDE ALL DEPENDENCIES --> <includes></includes> </dependencySet> </dependencySets>

在运行组装阶段时,会打包依赖项的 10.1.0.2.0 版本,而不是 11.1.0.0.0,我希望它会覆盖它,因为它实际上是在之前的编译阶段执行的大会。

我在这里犯错了吗?或者如果没有,有什么办法可以强制装配阶段更喜欢在子 pom 中声明的依赖项而不是父项?我用谷歌搜索过,但到目前为止都是空的......

【问题讨论】:

    标签: maven dependencies pom.xml maven-assembly-plugin parent-pom


    【解决方案1】:

    我认为正确的方法应该是更改父项使用标签dependencyManagement而不是依赖项,让子项目使用此依赖项或相互设置。

    但显然你不能改变父级。

    因此,您应该更改程序集描述符的dependencySet 配置。使用标签excludes 排除不需要的工件。

    您可以在此处阅读程序集描述符的手册参考: https://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

    【讨论】:

      猜你喜欢
      • 2014-10-26
      • 2011-02-05
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      相关资源
      最近更新 更多