我正在mvn package
上的分隔符文件夹中收集所有依赖项库,如下所示:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.copy.plugin}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
问题:这还包括<scope>test</scope>
个库。
我该如何排除这些库?
答案 0 :(得分:18)
使用includeScope
仅包含runtime
范围内的依赖项:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.copy.plugin}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
显然,<excludeScope>test</excludeScope>
似乎不受支持,因为test
范围涵盖所有依赖项(https://issues.apache.org/jira/browse/MDEP-85)。