Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a maven test scope from package phase?

Tags:

java

maven

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?

like image 818
membersound Avatar asked Feb 17 '15 13:02

membersound


1 Answers

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

like image 66
M A Avatar answered Sep 28 '22 08:09

M A