Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The command line is too long. in java project with maven

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.
like image 704
Kayser Avatar asked Nov 18 '11 10:11

Kayser


People also ask

How do I fix Intellij command line is too long?

In Intellij, go to "edit configurations" (Run -> Edit Configurations), in the configuration tab that comes up in the line "shorten command line" select option "classpath file"/"@argFiles (Java 9+)", last option in the drop down menu. Fixed it for me.

Can we run Maven project in command line?

Running a Maven build via the command lineTo build a Maven project via the command line, you use the mvn command from the command line. The command must be executed in the directory which contains the relevant pom file.


2 Answers

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.

like image 36
Matthew Farwell Avatar answered Sep 17 '22 15:09

Matthew Farwell


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 [email protected], 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)

like image 131
dermoritz Avatar answered Sep 20 '22 15:09

dermoritz