Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workaround(s) for maven-war-plugin error: Failed to copy file for artifact

If I have simple maven webapp project in Eclipse that depends on another maven project in my workspace, I get the error...

Failed to copy file for artifact [group:artifact:jar:version:compile] (org.apache.maven.plugins:maven-war-plugin:2.3:exploded:make-war-exploded:compile) pom.xml /Project line xx Maven Build Problem

It's mentioned several places online (debated across maven teams about what part is broken, how to fix it, etc) - with the only workaround I've found being "disable workspace resolution." Uhm, ok, but that's why I have that project in my workspace - so it can be edited and the changes get picked up without having to install every time.

We just recently converted to using maven so I don't have much experience with it - and somehow there are projects in our SVN that don't give that error even using the same configuration (they were created by a consultant who isn't here anymore). I can't figure out what the differences are - I've used almost identical poms, tried different versions of eclipse / war plugin, added build helper / wtp integration, created the projects in different ways, compared the eclipse configuration files, etc. The only difference I can figure is that those are deployed and I don't do that at home.

I just want that error to go away (without disabling workspace resolution) so I don't have to ignore all errors or get a dialog to confirm continuing each time I run. It's probably something simple I missed / don't know.

like image 284
Sean Dawson Avatar asked Dec 25 '12 06:12

Sean Dawson


3 Answers

This can be a problem with the m2eclipse plugin. To resolve this:

Open Project->Properties->Maven. Uncheck 'Resolve dependencies from Workspace projects' which solved the problem with the war plugin in m2eclipse.

like image 192
andresmafra Avatar answered Oct 14 '22 08:10

andresmafra


Looks like one other possible workaround is to (temporarily?) mark the dependency as having 'provided' scope. Or to ignore the maven-war-plugin executions (as seems to be the default now in the m2e-wtp lifecycle mapping metadata) - which again seems to defeat the purpose of using this in eclipse to automatically update things.

I'm surprised that no one else seems to be running into this with eclipse (or that disabling workspace resolution or ignoring execution appears to be acceptable for those who are).

like image 23
Sean Dawson Avatar answered Oct 14 '22 08:10

Sean Dawson


I was having the same problem and found a 'fix' that allowed everything to complete successfully. I closed all of the other projects in my Eclipse workspace. I believe there may be some lock Eclipse has on the files when the project is open?

like image 29
sixspin Avatar answered Oct 14 '22 06:10

sixspin