Why doesn't Maven's mvn clean ever work the first time?

It may be that your IDE or some other process is holding on to the the "target" folder and preventing maven from deleting it.


This is mostly caused by Windows Indexing. Excluding target folders or .jar extention from indexing will fix the problem. My best practice is excluding .jar extention.

To exclude target files:

  1. Click on windows icon/start menu
  2. Type indexing in search box and click on Indexing Options
  3. Then click on Modify button to investigate directories indexing.
  4. Remove checks of Target folders.

To excluse all .jar files:

  1. Click on windows icon/start menu
  2. Type indexing in search box and click on Indexing Options
  3. Then click on Advanced button.
  4. Go through File Types tab.
  5. In the list, find jar and uncheck it.

Turning off Window Search service on Win7 worked for me

Tags:

Maven 2