【问题标题】:The command line is too long. in java project with maven命令行太长。在带有maven的java项目中
【发布时间】:2012-01-01 03:20:08
【问题描述】:

我有 maven-gwt 项目。它有很多依赖项,这在大型项目中很常见。我认为这是创建类路径的极限。我找到了一些关于限制的信息。允许使用 1023 个字符。但我需要图书馆。

当我想打包我的项目 mit Maven 时收到以下错误。

The command line is too long.

我怎样才能解决这个问题?

这是 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 我在这行之后收到了错误--- maven-surefire-plugin:2.5:test (default-test)
  • 你能发布整个错误吗?
  • 实际上你的类路径限制似乎不是真的,如果我在一个相当大的项目上执行mvn dependency:build-classpath | wc -c,它会说10290...你mvn dependency:build-classpath | wc -c的输出是什么?谁在你的类路径中添加东西,maven 还是你自己添加的?
  • @christian-uhl Eclipse 或 maven 做。我在代码中所做的更改只是添加了更多依赖项。那是我对类路径的评价

标签: java maven command


【解决方案1】:

这似乎是 gwt-maven 的一个已知问题。有一个关于gwt-maven google groups的讨论:Workaround for windows command line length limit

问题似乎是源代码包含在测试类路径中,因此在运行 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 群组主题。

【讨论】:

    【解决方案2】:

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

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

    " 评论 40 来自 gaurav.a...@gmail.com,2009 年 3 月 23 日 “GWT 编译失败的问题的解决方法之一是 - 输入行是 太长了。”如下:

    1. 更改 m2(maven) 存储库。你可能有你的行家 存储库位于: C:\Documents and Settings\MahcineNameABC\.m2
    2. 从文件夹复制 settings.xml 文件 apache-maven-2.0.8\apache-maven-2.0.8\conf 转为C:\Documents and Settings\MahcineNameABC\.m2

      settings.xml 中:

    3. 将标签更改为 &lt;localRepository&gt;M:&lt;/localRepository&gt;。现在你的 m2 家就是一个虚拟的 M 盘。

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

    这将解决由于类路径中的条目过长而导致输入过长的问题 变量,至少在 Win XP SP2 中。从comment#22 对输入进行组合和测试 和#7。

    希望对你有帮助!

    这在大多数情况下应该会有所帮助(并且直到项目结束 - 至少在我的情况下)

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • 该参数与上述问题无关。
      【解决方案4】:

      如果您使用 Intellij,workspace.xml 中有一个设置可以解决此问题。有一个existing post about this

      【讨论】:

        猜你喜欢
        • 2018-08-08
        • 2019-07-04
        • 2018-09-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-16
        • 1970-01-01
        • 2016-07-29
        相关资源
        最近更新 更多