Maven-在清理阶段如何删除文件夹的内容? [英] Maven - how to delete contents of a folder during a clean phase?

查看:203
本文介绍了Maven-在清理阶段如何删除文件夹的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我有一个名为war的文件夹.它最初是空的,并且受版本控制.该文件夹在Maven的package阶段填充,并且Eclipse的WST插件从该文件夹部署Web应用.

in my project I have a folder called war. It is initially empty and it's under version control. The folder gets populated by Maven during its package phase and Eclipse's WST plugin deploys the web app from this folder.

我想要的是在clean阶段删除war文件夹的内容,而不是文件夹本身.我怎么做?到目前为止,我知道如何删除整个war文件夹:

What I want is to delete contents of the war folder during the clean phase but not the folder itself. How do I do that? So far I know how to delete the whole war folder:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
        <followSymLinks>false</followSymLinks>
        <filesets>
            <fileset>
                <directory>${basedir}/war</directory>
            </fileset>
        </filesets>
    </configuration>
</plugin>

如何仅删除war文件夹的内容而不删除文件夹本身?我知道通过添加一些现有的排除项,该文件夹将不会被删除.但是,通常如何只删除文件夹的内容?

How do I delete only contents of the war folder but not the folder itself? I know that by adding some existing excludes, the folder won't be deleted. But how to generally delete only contents of a folder?

推荐答案

将此includes部分添加到文件集定义

Add this includes section to your fileset definition

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>war</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>
    </plugins>
</build>

这篇关于Maven-在清理阶段如何删除文件夹的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆