How to exclude a maven test scope from package phase?

java, maven

Solution

Use an `includeScope` to include only `runtime` scoped dependencies:

<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>

Apparently, `<excludeScope>test</excludeScope>` does not seem to be supported because the `test` scope covers all dependencies (https://issues.apache.org/jira/browse/MDEP-85).

Problem

I'm collecting all dependency libraries in a separator folder on `mvn package` as follows: ``` <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> ``` Problem: this also include `<scope>test</scope>` libraries. How can I exclude these libs?

Original source