复制依赖传递和不传递 [英] copy dependencies transitive and not transitive

查看:39
本文介绍了复制依赖传递和不传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在pom.xml(jar包)中,我想利用maven依赖插件下载两种依赖.一种我想用传递性下载,另一种没有.到目前为止,我的插件部分包含以下元素:

In a pom.xml (jar packaging) i want to make use of the maven dependency plugin to download two kinds of dependencies. One kind i want to be downloaded with transitives and one without. Up to now, my plugins section contains follwing element:

<plugin>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.5</version>
  <executions>
    <execution>
  <id>Copy dependencies transitive</id>
  <phase>initialize</phase>
  <goals>
    <goal>copy-dependencies</goal>
  </goals>
      <configuration>
        <excludeTransitive>false</excludeTransitive>
    <outputDirectory>lib</outputDirectory>
        <includeArtifactIds>artifact_1</includeArtifactIds>
  </configuration>
</execution>

    <execution>
      <id>Copy dependencies not transitive</id>
  <phase>initialize</phase>
  <goals>
    <goal>copy-dependencies</goal>
  </goals>
  <configuration>
        <outputDirectory>samples</outputDirectory>
        <excludeTransitive>true</excludeTransitive>
        <includeArtifactIds>artifact_2,artifact_3</includeArtifactIds>
  </configuration>
</execution>
  </executions>
</plugin>

做完之后

mvn initialize

artifact_1 位于 lib 中,artifact_2 和 3 位于示例中.然而,artifacts_1 的传递依赖是找不到的.这是正确的方法吗?我以某种方式希望这个解决方案已经起作用,但它似乎没有......欢迎更正......

artifact_1 is located in lib and artifact_2 and 3 are located in samples. However artifacts_1's transitive dependencies cannot be found. Is this a right way to go? I somehow expect this solution to work already, but as it seems it does not... Corrections would be welcome...

推荐答案

刚发现是怎么回事...
includeArtifactIds 也会影响传递依赖.因此,如果 artifact_4 和 artifact_5 是 artifact_1 的传递依赖项,则它们不会被复制,因为我没有包含它们.我认为这有点出乎意料,但是……这就是它的实现方式(但没有记录).现在我刚刚从 includeArtifacts 更改为 excludeArtifacts 并且它有效.

Just found whats going on...
includeArtifactIds affects also the transitive dependencies. So if artifact_4 and artifact_5 are transitive dependencies of artifact_1 they are just not copied because i did not include them. I consider this a little unexpected, but well... thats how it was implemented (but not documented). Now i just changed from includeArtifacts to excludeArtifacts and it works.

这篇关于复制依赖传递和不传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆