【发布时间】:2016-04-18 22:59:14
【问题描述】:
我的私有存储库中有两个 Maven 工件,com.test.Parent 和 com.test.Child。 Child 依赖于 Parent。
我希望 Maven 做的唯一一件事就是下载 Child jar 及其依赖的所有内容,然后将其解压缩到一个目录中。
我能够通过调用mvn clean dependency:unpack 来组合一个pom.xml 来下载Child,但是为了下载传递依赖项,我必须手动将它包含在pom 中。
我想要的是调用,例如maven initialize,我需要的依赖项将被下载。我现在拥有的是这样的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.test</groupId>
<artifactId>Child</artifactId>
<version>1.2.3</version>
<type>jar</type>
<includes>**</includes>
<excludes>META-INF/**</excludes>
<outputDirectory>somepath/sources</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>unpack-dependencies</id>
<phase>initialize</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>false</excludeTransitive>
<includes>**</includes>
<outputDirectory>somepath/depend</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>Child</artifactId>
<version>1.2.3</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
</plugins>
但是,当我运行mvn clean initialize 时,只有子文件被下载并解压。
com.test.Child 的 POM 文件包含以下内容:
<groupId>com.test</groupId>
<artifactId>Child</artifactId>
<version>1.2.3</version>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>Parent</artifactId>
<version>7.8.9</version>
</dependency>
</dependencies>
您是否发现设置有任何问题?最终结果是开发者只需下载一个 pom.xml,运行mvn <something>,所有依赖项都会自动下载并解压到一定的结构。
谢谢
编辑:
当我删除本地 Maven 存储库并运行这个 pom 时,Child 和 Parent 都会被下载。所以存在依赖关系,但Parent 没有被unpack-dependencies 目标拾取。
【问题讨论】:
标签: maven dependencies