Java项目使用Maven时命令行过长。

9

I have maven-gwt project. It has lots of dependencies which is usual by a large project. I think it is at the limit with creation of classpath. I found some information about the limitation. Allowed is 1023 Character. But I need the libraries.

I receive the following error when i want to package my project mit Maven.

The command line is too long.

How can I get around the problem.?

Here is the expanded error in Jenkins:

[INFO] --- maven-surefire-plugin:2.5:test (default-test) @ MyProject ---
[INFO] Surefire report directory: C:\Documents and Settings\User\.jenkins\workspace\Myproject\target\surefire-reports
The command line is too long.
The command line is too long.

[ERROR] There are test failures.


哪个特定的插件导致了这个错误? - Matthew Farwell
@matthew-farwell 我在这行代码之后就遇到了错误 --- maven-surefire-plugin:2.5:test (default-test) - Kayser
实际上你的类路径限制似乎不正确,如果我在一个相当大的项目上执行 mvn dependency:build-classpath | wc -c,它会显示 10290。你的 mvn dependency:build-classpath | wc -c 输出是什么?是 Maven 添加东西到你的类路径中,还是你自己添加的? - Christian Uhl
@christian-uhl Eclipse或Maven可以完成这项工作。我在代码中所做的改变只是添加了更多的依赖项。这是我对类路径的假设。 - Kayser
我只在jenkins中看到了这个命令过长的错误。Eclipse只显示[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project AuswertungsDB: There are test failures. [ERROR] [ERROR] Please refer to C:\Workspaces_auf_C\GWT\ADB_Install\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] - Kayser
显示剩余8条评论
4个回答

6

我在这里找到了另一个解决方法http://code.google.com/p/gwt-maven/issues/detail?id=88 (我有更改pom以适应特定操作系统的问题)

简而言之:尽可能缩短本地存储库的路径。

" gaurav.a...@gmail.com在2009年3月23日发表评论40,针对“GWT编译由于输入行过长而失败”的问题,其中之一的解决方法如下:

  1. 更改m2(maven)存储库。 您可能拥有您的maven 存储库位于: C:\Documents and Settings\MahcineNameABC\.m2
  2. 从文件夹中复制settings.xml文件 apache-maven-2.0.8\apache-maven-2.0.8\confC:\Documents and Settings\MahcineNameABC\.m2

    settings.xml中:

  3. 更改标记为 <localRepository>M:</localRepository>。 现在你的m2主目录是虚拟的M驱动器。

  4. 创建存储库文件夹D:\maven-2.0.8\repository
  5. C:\Documents and Settings\MahcineNameABC\.m2\repository 剪切/复制所有文件/文件夹到D:\maven-2.0.8\repository
  6. 映射本地驱动器:打开命令提示符并执行(以创建虚拟驱动器):
    subst M: D:\maven-2.0.8\repository(帮助)
    现在一个虚拟的M驱动器将指向您的存储库。
  7. 使用值M设置环境变量M2_REPO
  8. 要启用长输入,在命令提示符上执行:cmd /e:32768

这将解决由于classpath变量中条目过长而导致的长输入问题,至少在Win XP SP2中是这样的。 评论#22和#7中结合测试了这些输入。

希望它有所帮助!

这将在大多数情况下有所帮助(至少在我的情况下直到项目结束)


2
这似乎是gwt-maven已知的问题。在gwt-maven的google小组上有一次讨论:解决Windows命令行长度限制的方法
问题似乎是测试类路径中包括了源代码,因此在运行surefire时会出现问题:
解决方法是排除源代码依赖项,并将其系统范围设为(来自上述线程):
    <dependency> 
        <!-- non existant artifact ID required (-source) maven bug?? --> 
        <artifactId>myproject-rpc-source</artifactId> 
        <groupId>${project.groupId}</groupId> 
        <version>${project.version}</version> 
        <classifier>sources</classifier> 

        <!-- hack below as maven only incudes provdied in test scope --> 
        <scope>system</scope> 
        <systemPath>${basedir}/../rpc/target/myproject-rpc-${project.version}-sources.jar</systemPath> 
    </dependency> 

但在进行此操作之前,我建议您完全阅读并理解Google Groups主题线。

1
如果你正在使用Intellij,workspace.xml中有一个设置可以解决这个问题。这里有一个关于此的现有帖子

-1
从2.5.0-rc1版本开始,GWT Maven插件有一个新选项:“genParam”。将此参数设置为false以避免此问题。

该参数与所提到的问题无关。 - Sergey Makarov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接