Remove directory with maven-clean-plugin

zappee picture zappee · Dec 14, 2017 · Viewed 11.9k times · Source

Can I delete directory with maven-clean-plugin?

The following configuration deletes files from the given directory but the directory itself will be remained:

<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>

I have checked the plugin's documentation but I can not see any way to delete the directory: http://maven.apache.org/plugins-archives/maven-clean-plugin-2.6.1/clean-mojo.html

I need to delete the directory as well.

Answer

zappee picture zappee · Dec 14, 2017

Finally I have figured out what is the solution. The file pattern what I used was wrong.

The following file mask deletes files from the given directory but the folder will be remained:

<include>**/*</include>

This pattern deletes the directory as well:

<include>**</include>