问题
Using vagrant, I git clone
'd my java app to c:/shared
. In my Vagrantfile
, I specified that my host's c:/shared
will be mapped to /home/vagrant/myapp
on my Virtual Machine.
When I run mvn clean compile
from within the VM, I ran into this error:
core/myapp/target/classes/com/myapp/...
at org.apache.maven.plugin.clean.CleanMojo.execute(CleanMojo.java:215)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.io.IOException: Failed to delete core/myapp/target/classes/com/myapp/...
at org.apache.maven.plugin.clean.Cleaner.delete(Cleaner.java:249)
at org.apache.maven.plugin.clean.Cleaner.delete(Cleaner.java:191)
at org.apache.maven.plugin.clean.Cleaner.delete(Cleaner.java:158)
However, the Maven build succeeds on my Windows (host) machine.
Running ls
gives an odd output as the privileges show up as question marks(?):
[vagrant-centos65 parent]$ ls -lrot target/...
ls: cannot access ...
?????????? ? ? ? ? $Class$$doMethod$1$1$$anonfun$apply$2.class
I'm running as user kevin
, where as /home/vagrant/myapp
is owned by vagrant
. However, most, if not all, of myapp
's directories have wide open (766
or 777
) rights.
In the past, I've successfully compiled on the guest VM in a directory shared between host and guest.
I'm using:
vagrant - 1.3.5
Maven - 3.2.1
VirtualBox - 4.3.8
Also, I observed that this particular folder (C:
) is not being indexed per this post.
EDIT I'm seeing the same error even when hosting the file with smb.
Why would the build succeed on the host, but not the guest?
回答1:
Had a similar problem, but mainly because I was dumb and had Eclipse running on the host with a project in the shared area abd 'build automatically' selected.
So every time maven deleted a target file, eclipse would recreate it...
回答2:
During compilation, Maven compiled Scala source files into CLASS
files.
The length of one .class
file was 161. The path's length to this file was ~100.
161 + ~90 = ~261 # exceeds the 255 path length on Windows
In order to fix this problem, @monkjack informed me how to limited the length of a generated CLASS file to 75 characters - https://stackoverflow.com/a/23138361/409976.
来源:https://stackoverflow.com/questions/23089023/maven-clean-fails-on-linux-vagrant-shared-drive