Maven Clean Fails on Linux Vagrant Shared Drive

*爱你&永不变心* 提交于 2020-01-06 04:26:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!