0

I have created an additional target directory called "dist" to which I am copying some build artifacts. Because it is not in the default target directories, I add an appropriate to the clean plugin configuration per Delete Additional Files instructions for the plugin, as follows:

        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <fileset>
                    <followSymlinks>false</followSymlinks>
                    <directory>dist</directory>
                    <includes>
                        <include>*</include>
                    </includes>
                </fileset>
            </configuration>
        </plugin>

But the "dist" directory and its contents remains after any "mvn clean". I've tried a number of variants, and checked the output of "mvn help:effective-pom" or the "mvn -X" debug output and, I find:

  1. The configuration is showing up in submodules' effective pom's.
  2. There is no error message
  3. There is no sign of "dist" directories or their contents in the debug output.
  4. Explicit references like <directory>${basedir}/dist</directory> make no difference.
  5. Likewise, using more or less explicit <include> references like ".jar" or "*/*.txt" make no difference.

I'm using maven 3.0.3, clean plugin 2.5. I tried 2.4, just in case. No difference. Also, no permission problems.

I've scanned dozens of examples in Google, and all merely repeat the documentation's instructions. I am relatively new to Maven and still learning. Am I blind to something obvious? Thanks.

carlspring
  • 31,231
  • 29
  • 115
  • 197
K Markey
  • 595
  • 1
  • 6
  • 10

4 Answers4

2

You need to include the <fileset> tag within the <filesets> tag

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <configuration>
        <filesets>
            <fileset>
                <directory>dist</directory>
            </fileset>
        </filesets>
    </configuration>
</plugin>
Lan
  • 6,470
  • 3
  • 26
  • 37
1

Almost,

Here's a working one:

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
    <filesets>
        <fileset>
            <followSymlinks>false</followSymlinks>
            <directory>${basedir}</directory>
            <includes>
                <include>dist/**</include> 
                <include>target</include> 
            </includes>
        </fileset>
    </filesets>
</configuration>

asaf000
  • 606
  • 6
  • 13
0

Try to use instead of:

                  <includes>
                        <include>*</include>
                  </includes>

Something like

                   <includes>
                        <include>**/*.*</include>
                   </includes>

It worked for me using Maven 2.2.1

pvm14
  • 544
  • 3
  • 11
0

This will work:

    <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <configuration>
            <fileset>
                <followSymlinks>false</followSymlinks>
                <directory>${basedir}</directory> <!-- Careful with this -->
                <includes>
                    <include>dist</include> 
                    <include>target</include> 
                </includes>
            </fileset>
        </configuration>
    </plugin>
carlspring
  • 31,231
  • 29
  • 115
  • 197