Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse 'refresh automatically' and Maven build interference

I recently configured Eclipse (ver. 3.6) in order to make it automatically refresh projects in the workspace (Windows > Preferences > General > Workspace > Refresh Automatically).

Since I changed this configuration I have the following problem when I try to run Maven (Maven install from Eclipse) to build a big project:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project ProjectName: Failed to clean project: Failed to delete C:\ProjectName\target -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

The problem occurs randomly (more or less 50% of the times I build a single project), but when I try to build 14 projects all together I always get this error somewhere. I think that the problem is that Maven is trying to delete files that are locked by Eclipse (that is refreshing the project). In fact it doesn't happen when I disable the "Refresh Automatically" option.

Does anybody know a trick to avoid this trouble?

I noticed there is another question "Eclipse automatically refresh resources and exclude build dir" about this topic, but there are no answers. I hope I provided enough information to understand the problem.

like image 224
simo Avatar asked Nov 14 '22 22:11

simo


1 Answers

This occurs because something, most likely eclipse, has a lock on the file during refresh so when maven tries to clean (i.e. delete the target directory), it fails. Don't refresh automatically; I typically only have eclipse refresh the workspace when it initially runs.

like image 139
tdrury Avatar answered Dec 06 '22 14:12

tdrury