Kingamere
Kingamere

Reputation: 10122

Maven dependency plugin - exclude directories when unpackaging jar file

I am trying to un-package a jar file using the maven dependency plugin. But I only want one file inside the jar file and want to exclude the META-INF directory that's inside the jar. How would I do this?

This is what I have so far:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.0.2</version>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>...</groupId>
                        <artifactId>...</artifactId>
                        <version>...</version>
                        <type>jar</type>
                        <outputDirectory>${project.basedir}/src/test/</outputDirectory>
                        <excludes>META-INF</excludes>
                    </artifactItem>
                </artifactItems>
                <excludes>META-INF</excludes>
            </configuration>
        </execution>
    </executions>
</plugin>

Upvotes: 6

Views: 6630

Answers (1)

Kingamere
Kingamere

Reputation: 10122

Found the solution.

<artifactItem>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
    <type>jar</type>
    <outputDirectory>${project.basedir}/src/test/</outputDirectory>
    <excludes>META-INF/</excludes>
</artifactItem>

Just add a forward slash: / after the directory name.

Upvotes: 12

Related Questions