Maven依赖插件 - 在解压jar文件时排除目录

6
我正在尝试使用Maven依赖插件解压jar文件。但是我只需要jar文件中的一个文件,并且要排除jar内部的META-INF目录。如何做到这一点?
以下是我目前的代码:
<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>
1个回答

11

找到了解决方案。

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

只需在目录名称后面添加斜杠:/

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接