简体   繁体   中英

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM