【问题标题】:Remove directory with maven-clean-plugin使用 maven-clean-plugin 删除目录
【发布时间】:2018-05-28 04:33:51
【问题描述】:

我可以使用 maven-clean-plugin 删除目录吗?

以下配置从给定目录中删除文件,但目录本身将保留:

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
        <filesets>
            <fileset>
                <directory>src/main/javascript/node_modules</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <followSymlinks>false</followSymlinks>
            </fileset>
        </filesets>
    </configuration>
</plugin>

我已经检查了插件的文档,但我看不到任何删除目录的方法:http://maven.apache.org/plugins-archives/maven-clean-plugin-2.6.1/clean-mojo.html

我也需要删除目录。

【问题讨论】:

标签: java maven maven-clean-plugin


【解决方案1】:

我终于找到了解决方案。我使用的文件模式是错误的。

以下文件掩码会从给定目录中删除文件,但该文件夹将保留:

<include>**/*</include>

此模式也会删除目录:

<include>**</include>

【讨论】:

    【解决方案2】:

    在配置标签中为 'excludeDefaultDirectories>' 使用 true。 maven插件版本不低于2.3

    <excludeDefaultDirectories>true</excludeDefaultDirectories>
    

    【讨论】:

    • 请使用最新版本的插件,目前是3.0.0 以下将显示插件的最新版本:maven.apache.org/plugins
    • 不幸的是它没有解决我的问题。目录还在。
    猜你喜欢
    • 2015-11-26
    • 2015-04-23
    • 2017-04-22
    • 2017-06-08
    • 1970-01-01
    • 2016-06-05
    • 2014-11-07
    • 2016-04-11
    • 2020-01-25
    相关资源
    最近更新 更多