mavenmaven-clean-plugin

Can the directories wiped by mvn clean be customized?


After running

mvn clean

I had kind of a bad moment when trying to run a binary in my project. First the selected binary did not run - then discovered the entire /bin directory had been removed. After a bit of a panic it came out that - among the durable/checked in files - only the bin directory had been nuked.

Here is a snippet of the results of the mvn clean : while the libs dir is desirable to remove .. the bin is not.

--- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO] Deleting /git/OCspark/bin (includes = [], excludes = [])
[INFO] Deleting /git/OCspark/libs (includes = [**/*.jar], excludes = [])

Is there a configuration to inform clean what is "OK" to wipe and what is "off limits" ?


Solution

  • You can configure the maven-clean-plugin to include and exclude the additional files. Check for any existing inclusions and exclusions.

    Alternatively, you can try to use two filesets in the configuration for include and exclude separately, somewhat like(not tested) :

    <configuration>
      <filesets>
        <fileset>
          <directory>/git/OCspark/libs</directory>
          <includes>
            <include>**/*.*</include>
          </includes>
          <followSymlinks>false</followSymlinks>
        </fileset>
        <fileset>
          <directory>/git/OCspark/bin</directory>
          <excludes>
            <exclude>**/*.*</exclude>
          </excludes>
          <followSymlinks>false</followSymlinks>
        </fileset>
      </filesets>
    </configuration>