3

While developing an application, the command I use most often is mvn clean install. Cleaning probably isn't needed 90% of the time, but it does not hurt and might help to avoid weird issues. There are however times, when I'm working on a console application, when I have trunk open on one terminal, and target on another.

mvn clean in such a case does what I need it to - it deletes every file within the target folder - and then fails due to lock on the folder itself. Is there a way to tell it, that in such a case it should just ignore/skip deleting the folder itself and continue with install?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Deltharis
  • 2,320
  • 1
  • 18
  • 29

1 Answers1

2

Yes, you can configure the maven-clean-plugin to ignore errors with the help of the failOnError attribute. It defaults to true, meaning that the plugin will fail on error.

Sample configuration to disable this:

<plugin>
  <artifactId>maven-clean-plugin</artifactId>
  <version>3.0.0</version>
  <configuration>
    <failOnError>false</failOnError>
  </configuration>
</plugin>

You can also do it directly on the command line, without changing the POM, by setting the maven.clean.failOnError user property:

mvn clean install -Dmaven.clean.failOnError=false

Note that this make the plugin ignore all errors, however it is not currently possible to make it ignore only certain types of errors.

Tunaki
  • 132,869
  • 46
  • 340
  • 423