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:
- Click on windows icon/start menu
- Type indexing in search box and click on Indexing Options
- Then click on Modify button to investigate directories indexing.
- Remove checks of Target folders.
To excluse all .jar files:
- Click on windows icon/start menu
- Type indexing in search box and click on Indexing Options
- Then click on Advanced button.
- Go through File Types tab.
- In the list, find jar and uncheck it.
Turning off Window Search service on Win7 worked for me