Maven Clean 在 Linux Vagrant 共享驱动器上失败 [英] Maven Clean Fails on Linux Vagrant Shared Drive

查看:46
本文介绍了Maven Clean 在 Linux Vagrant 共享驱动器上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 vagrant,我 git clone 将我的 Java 应用程序设置为 c:/shared.在我的 Vagrantfile 中,我指定我的主机的 c:/shared 将映射到我的虚拟机上的 /home/vagrant/myapp.

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.

当我在 VM 中运行 mvn clean compile 时,我遇到了这个错误:

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)

但是,Maven 构建在我的 Windows(主机)机器上成功.

However, the Maven build succeeds on my Windows (host) machine.

运行 ls 会给出奇怪的输出,因为权限显示为问号 (?):

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

我以用户 kevin 运行,其中 /home/vagrant/myappvagrant 所有.但是,大多数(如果不是全部)myapp 的目录都具有广泛的开放(766777)权限.

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.

过去,我在来宾 VM 上的主机和来宾共享目录中成功编译.

In the past, I've successfully compiled on the guest VM in a directory shared between host and guest.

我正在使用:

vagrant - 1.3.5
Maven - 3.2.1
VirtualBox - 4.3.8

此外,我观察到此特定文件夹 (C:) 并未按照此 帖子.

Also, I observed that this particular folder (C:) is not being indexed per this post.

编辑即使在使用 smb.

为什么构建会在主机上成功,而在来宾上却没有?

Why would the build succeed on the host, but not the guest?

推荐答案

在编译期间,Maven 将 Scala 源文件编译为 CLASS 文件.

During compilation, Maven compiled Scala source files into CLASS files.

一个 .class 文件的长度为 161.此文件的路径长度约为 100.

The length of one .class file was 161. The path's length to this file was ~100.

161 + ~90 = ~261 # 超过 Windows 上的 255 路径长度

161 + ~90 = ~261 # exceeds the 255 path length on Windows

为了解决这个问题,@monkjack 告诉我如何将生成的 CLASS 文件的长度限制为 75 个字符 - https://stackoverflow.com/a/23138361/409976.

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.

这篇关于Maven Clean 在 Linux Vagrant 共享驱动器上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆