Maven 构建 - surefire 插件错误 - 文件名太长

Maven build - surefire plugin error - File name too long

我像往常一样使用 mvn clean install 构建项目,但发生了以下错误:

(File name too long) -> [Help 1]

完整的 Maven 输出:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:19 min
[INFO] Finished at: 2017-02-23T13:42:19+01:00
[INFO] Final Memory: 67M/544M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project union-sme-webapp: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: java.lang.RuntimeException: org.apache.maven.surefire.report.ReporterException: When writing report: /home/gondy/projects/xxxxxxx/xxxxxxxxx/webapp/target/surefire-reports/TEST-xx.xxxxx.xxxx.xxxx.webapp.service.document.generator.statics.arrangements.XxxxxxxxxxXxxxxxxXxxxxxxxxxxxXxxxxxxxXxxxxxxxxXxxx.xml (File name too long) -> [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.

我正在开发 Ubuntu 16.04 LTS。我的同事正在毫无问题地构建同一个项目,它甚至可以在 Jenkins CI 上运行。这里有什么问题?文件名长度为 144 个字符,应该没问题,ext 有 255 个字符的限制。

问题是,我已经加密了主目录并且 Ubuntu 只允许文件名长度为 143 个字符:

来自 eCryptfs 的一位作者:

Empirically, we have found that character filenames longer than 143 characters start requiring >255 characters to encrypt. So we (as eCryptfs upstream developers) typically recommend you limit your filenames to ~140 characters. https://unix.stackexchange.com/a/32834/82647

所以选项基本上是:

  • 通过重命名方法缩短文件名 类
  • 将您的项目移出加密目录
  • 删除主目录的加密

您始终可以通过 pom.xml 文件或控制台参数禁用文件报告

mvn clean install -Dsurefire.useFile=false -DredirectTestOutputToFile=false -DdisableXmlReport=true

测试结果将记录到控制台

其他方式(未经我测试)将汇总报告,此处提到 maven surefire reporting plugin configuration