Title: maven-clean-plugin is not removing all given directories
Tags: java;maven;maven-3;maven-plugin;maven-clean-plugin
Question: In my project ```.pom``` I set up the ```maven-clean-plugin``` like so:

```<plugin&gt;
  <artifactId&gt;maven-clean-plugin</artifactId&gt;
  <version&gt;2.6.1</version&gt;
  <configuration&gt;
    <filesets&gt;
      <fileset&gt;
        <directory&gt;src/main/webapp/bower_components</directory&gt;
      </fileset&gt;
      <fileset&gt;
        <directory&gt;node_modules</directory&gt;
      </fileset&gt;
      <fileset&gt;
        <directory&gt;node</directory&gt;
      </fileset&gt;
    </filesets&gt;
  </configuration&gt;
 </plugin&gt;
```

The plugin purpose is to remove directories which are created by ```frontend-maven-plugin```. Anyway the last one works OK.



Problem

Now the issue is that for no reason, one of the above folders is never removed. And it is always the one "in the middle". I added 3 ```filesets``` and always the 2nd one is not removed, see logs:

```[INFO] Deleting /src/main/webapp/bower_components (includes = [], excludes = [])
[INFO] Deleting /node_modules (includes = [.bindings], excludes = [])
[INFO] Deleting /node (includes = [], excludes = [])
```

If I change folders' order:

```[INFO] Deleting /src/main/webapp/bower_components (includes = [], excludes = [])
[INFO] Deleting /node (includes = [.bindings], excludes = [])
[INFO] Deleting /node_modules (includes = [], excludes = [])
```

And also the 2nd option always contains this part: ```includes = [.bindings]``` which I believe results in the folder not being deleted. 

Why is that happening, and how to fix it?



EDIT, debug log

```mvn -X clean``` result, I think this is where it breaks:

http://pastebin.com/ep1i2Bjk

After parsing the ```pom.xml``` it reads the configuration with this parameter. However, I did not put it there.

Comment: run `mvn` command with `-X` option to see full logs.

Comment: @FranMontero see update

Comment: @khmarbaise because I want to remove the directory, not it's content. Why one folder is deleted OK and another is not?

Comment: @khmarbaise You do not need to specify the content of the folder. Obviously, what is inside should be deleted.

Comment: You have not defined what to include nor what's excluded...See the [example in the documentation](http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html). BTW: Just try `mvn -D clean.verbose=true package` Apart from that the output shows all configuration parts inclusive those which are defaults for the plugin.

Comment: Sorry...you wan't to remove a directory without removing it's content ? I assume i misunderstand a thing but from my point of view it does not make sense to try to delete a directory without removing it's content.

Here is the accepted answer: OK I have found the issue! It is actually a bug in the plugin and is already reported. It affects the ```maven-clean-plugin 2.6.1```.

It was my side misconfiguration, read on for the resolution.

Situation

You have a parent project and a child project, both have to use the plugin.

Now; 


in parent project you specify some filesets.
in child project you specify some filesets. 




What I think is expected:

Plugin read both parent's and child's filesets and cleans them all.

What happens:

Plugin OVERRIDES the parent's filesets with child's filesets. Filesets are overriden in order. HOWEVER the parents configuration for the fileset is not cleared!



My situation:
Parent .pom:

```<filesets&gt;
   <fileset&gt;
      <directory&gt;test-output</directory&gt;
   </fileset&gt;
   <fileset&gt;
     <directory&gt;${basedir}/</directory&gt;
     <includes&gt;
        <include&gt;.bindings</include&gt;
     </includes&gt; 
   </fileset&gt;
</filesets&gt;
```

Childs pom:

```<filesets&gt;
    <fileset&gt;
        <directory&gt;node</directory&gt;
    </fileset&gt;
    <fileset&gt;
        <directory&gt;node_modules</directory&gt;
    </fileset&gt;
    <fileset&gt;
        <directory&gt;src/main/webapp/bower_components</directory&gt;
    </fileset&gt;
</filesets&gt;
```

And with the above information; the config read by plugin is:

```<filesets&gt;
    <fileset&gt;
        <directory&gt;node</directory&gt;
    </fileset&gt;
    <fileset&gt;
        <directory&gt;node_modules</directory&gt;
        <includes&gt;
            <include&gt;.bindings</include&gt;
        </includes&gt;
    </fileset&gt;
    <fileset&gt;
        <directory&gt;src/main/webapp/bower_components</directory&gt;
    </fileset&gt;
</filesets&gt;
```

instead of a config with 5 filesets.

Bug report https://issues.apache.org/jira/browse/MCLEAN-64

RESOLVED

```
  For configuration there are some magic attributes to instruct how xml elements should be combined. In this case add combine.children="append" to the filesets tag. More details about this can be found on the POM Reference page. http://maven.apache.org/pom.html
```

Worth mentioning is that it is enough to set ```combine.children="append"``` in child's project ```.pom```.

Comment for this answer: On the same note, I had an empty plugin definition on the parent. I deleted the `maven-clean-plugin` from the parent and my child clean worked.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 6, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:09/01/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><maven><maven-3><maven-plugin><maven-clean-plugin>', 'Title': 'maven-clean-plugin is not removing all given directories', 'ViewCount': 5471, 'id': 32329141, 'user_AboutMe': '', 'user_AccountId': 1685801.0, 'user_DisplayName': 'Atais', 'user_Reputation': 10297.0, 'user_Views': 872.0, 'user_id': 1549135.0}}