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

时间:2017-10-30 20:56:58

标签: java maven jar

我正在尝试使用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 个答案:

答案 0 :(得分:5)

找到了解决方案。

add_shortcode('my_further_information_list','my_further_information_list_func');
function my_further_information_list_func(){
        $additional_info_1 = get_field( 'additional_info_1');
        $additional_info_2 = get_field( 'additional_info_2');
        $additional_info_3 = get_field( 'additional_info_3');
        $html = "<ul>";
        if ( $additional_info_1) {
            $html .= '<li>'.$additional_info_1.'</li>';
        }
        if ( $additional_info_2) {
            $html .= '<li>'.$additional_info_2.'</li>';
        }
        if ( $additional_info_3) {
            $html .= '<li>'.$additional_info_3.'</li>';
        }
        $html .= "</ul>";
        return $html;
}

只需在目录名后添加正斜杠:<artifactItem> <groupId>...</groupId> <artifactId>...</artifactId> <version>...</version> <type>jar</type> <outputDirectory>${project.basedir}/src/test/</outputDirectory> <excludes>META-INF/</excludes> </artifactItem>