Maven 依赖插件:只复制测试依赖
Maven Dependency Plugin: Copy only test dependencies
我已经使用 Maven 依赖插件 assemble 在一个输出目录中为我的项目设置了所有运行时依赖项。现在我想 assemble 所有额外的测试依赖项在一个单独的目录中。
但是当我包含范围 test
并排除 compile
或 runtime
范围时,它仍然总是复制所有编译依赖项。
有没有办法只复制额外的测试依赖项?
我目前的配置:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-test-libs</id>
<phase>generate-test-resources</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<outputDirectory>${project.build.directory}/test-libs</outputDirectory>
<includeScope>test</includeScope>
<excludeScope>compile</excludeScope>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
includeScope
parameter, by default, is empty which means it includes all scopes and the excludeScope
默认为空。
当您指定 <includeScope>test</includeScope>
时,这意味着您要包括所有依赖项(所有范围的)。此设置似乎与默认的空值不同,我猜 maven-dependency-plugin
在同时使用 <excludeScope>
和 <includeScope>
时会混淆:它包括所有内容并且不排除指定的范围。
您需要删除 includeScope
并让 excludeScope
完成它的工作。
我已经使用 Maven 依赖插件 assemble 在一个输出目录中为我的项目设置了所有运行时依赖项。现在我想 assemble 所有额外的测试依赖项在一个单独的目录中。
但是当我包含范围 test
并排除 compile
或 runtime
范围时,它仍然总是复制所有编译依赖项。
有没有办法只复制额外的测试依赖项?
我目前的配置:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-test-libs</id>
<phase>generate-test-resources</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<outputDirectory>${project.build.directory}/test-libs</outputDirectory>
<includeScope>test</includeScope>
<excludeScope>compile</excludeScope>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
includeScope
parameter, by default, is empty which means it includes all scopes and the excludeScope
默认为空。
当您指定 <includeScope>test</includeScope>
时,这意味着您要包括所有依赖项(所有范围的)。此设置似乎与默认的空值不同,我猜 maven-dependency-plugin
在同时使用 <excludeScope>
和 <includeScope>
时会混淆:它包括所有内容并且不排除指定的范围。
您需要删除 includeScope
并让 excludeScope
完成它的工作。