How to delete a folder at maven clean phase?

4k views Asked by At

I want do delete a folder at clean phase.

I have used maven-clean-plugin and successfully deleted all of the files under it.

        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>

            <configuration>
                <filesets>
                    <fileset>
                        <directory>GENERATED_DIR</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

I want to delete "GENERATED_DIR" as well.

2

There are 2 answers

0
aurelius On BEST ANSWER

This finally worked for me

        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>${basedir}</directory>
                        <includes>
                            <include>**/GENERATED_DIR/**</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>
4
Essex Boy On

The following works for me

    <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
            <filesets>
                <fileset>
                    <directory>${basedir}/GENERATED_DIR</directory>
                </fileset>
            </filesets>
        </configuration>
    </plugin>