如何从包阶段中排除maven测试范围?

mem*_*und 10 java maven

我正在收集分隔符文件夹中的所有依赖库,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>
Run Code Online (Sandbox Code Playgroud)

问题:这也包括<scope>test</scope>库.我该如何排除这些库?

man*_*uti 21

使用a 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>
Run Code Online (Sandbox Code Playgroud)

显然,<excludeScope>test</excludeScope>似乎不支持,因为test范围涵盖所有依赖项(https://issues.apache.org/jira/browse/MDEP-85).

  • 我试过了,但出现以下错误:`不能排除测试范围,这将排除所有内容。-&gt; [帮助 1]` (3认同)