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.
Kayser
  • 6,544
  • 19
  • 53
  • 86
  • Which particular plugin is giving this error? – Matthew Farwell Nov 18 '11 at 10:42
  • @matthew-farwell I got the error just after this line `--- maven-surefire-plugin:2.5:test (default-test) ` – Kayser Nov 18 '11 at 10:46
  • Can you post the whole error? – JoseK Nov 18 '11 at 10:47
  • Actually your classpath limit does not seem to be true, If i execute `mvn dependency:build-classpath | wc -c` on a reasonably large project it says 10290... What is your output of `mvn dependency:build-classpath | wc -c` ? Who does add stuff to your classpath, maven or do you add it yourself? – Christian Uhl Nov 18 '11 at 10:48
  • @christian-uhl Eclipse or maven do it. What i changed in my code is just adding more dependencies. That was my auumption with classpath – Kayser Nov 18 '11 at 10:53
  • I see this error with command too long only in jenkins. Eclipse say only `[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 Nov 18 '11 at 10:54
  • Try rerun with `mvn -X` for a more descriptive message before the failure. You might see which line is too long. – JoseK Nov 18 '11 at 11:05
  • it tries to execute following: `Forking command line: cmd.exe /X /C "C:\Programme\JAVA\jdk1.6.0_20\jre\bin\java -classpath "MANY CLASSPATH PATHS.." org.apache .maven.surefire.booter.SurefireBooter C:\DOKUME~1\STL1309\LOKALE~1\Temp\surefire8733536338535403800tmp C:\DOKUME~1\STL13 09\LOKALE~1\Temp\surefire1935817605293835178tmp"` The problem it does not show the error in command shell only in jenkins – Kayser Nov 18 '11 at 11:16
  • Are you able to run this line standalone `java -classpath "MANY CLASSPATH PATHS.." org.apache .maven.surefire.booter.SurefireBooter C:\DOKUME~1\STL1309\LOKALE~1\Temp\surefire8733536338535403800tmp C:\DOKUME~1\STL13 09\LOKALE~1\Temp\surefire1935817605293835178tmp"` from a cmd window? – JoseK Nov 18 '11 at 11:22
  • Have you considered building on non-Windows? Every other desktop OS out there has _much_ higher limits on command line length, and running Linux in a VM is pretty easy… – Donal Fellows Nov 18 '11 at 11:43
  • it is not possible to execute from a command line. CMD doesn't allow after 8191 (2^13) characters. – Kayser Nov 18 '11 at 12:17
  • if this error is given running the result of maven appassembler plugin, a simple solution is to specify absolute short - in my case ${project.build.directory} ended up too long, i guess.. – hello_earth Nov 22 '17 at 10:58
  • FYI: "_The command line is too long._" appears also with [`new DefaultInvoker().execute( InvocationRequest.setProperties( System.getProperties ) );`](https://maven.apache.org/shared/maven-invoker/apidocs/org/apache/maven/shared/invoker/InvocationRequest.html#setProperties-java.util.Properties-). – Gerold Broser Jan 01 '21 at 11:37

4 Answers4

6

I found another workaround here http://code.google.com/p/gwt-maven/issues/detail?id=88 (I have problem with changing pom to fit a specific OS)

In short: make path to local repository as short as possible.

" Comment 40 by gaurav.a...@gmail.com, Mar 23, 2009 One of the fix to the problem of "GWT compilation fails due to- The input line is too long." is as follows:

  1. Change m2(maven) repository. You might have your maven repository at: C:\Documents and Settings\MahcineNameABC\.m2
  2. Copy settings.xml file from folder apache-maven-2.0.8\apache-maven-2.0.8\conf into C:\Documents and Settings\MahcineNameABC\.m2

    In settings.xml:

  3. change the tag as <localRepository>M:</localRepository>. Now your m2 home is a virtual M drive.

  4. Create a repository folder as D:\maven-2.0.8\repository
  5. Cut/Copy all the files/folders from C:\Documents and Settings\MahcineNameABC\.m2\repository to D:\maven-2.0.8\repository
  6. Map local drive: open command prompt and execute (to create the virtual drive):
    subst M: D:\maven-2.0.8\repository(help)
    Now a virtual M drive will point to your repository.
  7. Set environment variable M2_REPO with value M:
  8. To enable long inputs, on command prompt execute:cmd /e:32768

This would fix the problem of long inputs due to very long entries in classpath variables, at least in Win XP SP2. The inputs are combined and tested from comment#22 and #7.

Hope it helps!

This should help in most cases (and 'til the end of project - at least in my case)

Naveen Reddy Marthala
  • 2,622
  • 4
  • 35
  • 67
dermoritz
  • 12,519
  • 25
  • 97
  • 185
2

This seems to be a known problem with gwt-maven. There is a discussion on the gwt-maven google groups: Workaround for windows command line length limit

The problem seems to be that the sources are included on the test classpath, hence you're getting problems when you're running surefire:

The workaround is to exclude the sources dependency, make it system scope (from the above thread):

    <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> 

but I would fully read and understand the google groups thread before proceeding with this.

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
1

If you are using Intellij there is a setting in workspace.xml that takes care of this issue. There is an existing post about this.

Community
  • 1
  • 1
eze
  • 2,332
  • 3
  • 19
  • 30
-1

From 2.5.0-rc1 the GWT Maven plugin has a new option: "genParam". Set this param to false to aviod this problem.

haromt
  • 81
  • 1
  • 7