【问题标题】:copy dependencies transitive and not transitive复制依赖传递和不传递
【发布时间】:2012-08-15 17:14:14
【问题描述】:

在 pom.xml(jar 打包)中,我想利用 maven 依赖插件下载两种依赖项。我想下载一种带及物的,一种不带。到目前为止,我的插件部分包含以下元素:

<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 位于 samples 中。但是,artifacts_1 的传递依赖项找不到。这是正确的方法吗?我不知何故希望这个解决方案已经可以工作,但它似乎没有......欢迎更正......

【问题讨论】:

    标签: maven maven-dependency-plugin


    【解决方案1】:

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

    【讨论】:

    • 是的,似乎包含/排除适用于指定和派生(传递)deps 的整个已解析列表,这很痛苦......
    猜你喜欢
    • 2018-07-06
    • 2014-12-20
    • 2021-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-08
    相关资源
    最近更新 更多