Skip to content

Commit

Permalink
[SUREFIRE-727] Classpath too long on windows with useManifestOnlyJar=…
Browse files Browse the repository at this point in the history
…false

git-svn-id: https://svn.apache.org/repos/asf/maven/surefire/trunk@1095173 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
krosenvold committed Apr 19, 2011
1 parent 3a0e37a commit d6e6a84
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
Expand Up @@ -48,7 +48,13 @@ java -classpath foo.jar:bar.jar MyApp
your command line, and therefore a limit on how long you can make your classpath. The limit is different
on different versions of Windows; in some versions only a few hundred characters are allowed, in others
a few thousand, but the limit can be pretty severe in either case.


* Update for Surefire 2.8.2

It turns out setting the CLASSPATH as an environment variable may remove most of the
practical length limitations, as documented in http://jira.codehaus.org/browse/SUREFIRE-727. This means
most of the length-related problems in this article may be outdated.

* How do people solve this problem in general?

There are two "tricks" you can use to workaround this problem; both of them are can cause other problems in some cases.
Expand Down
Expand Up @@ -19,15 +19,6 @@
* under the License.
*/

import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.util.Relocator;
import org.apache.maven.surefire.util.UrlUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.Commandline;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -39,6 +30,14 @@
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.util.Relocator;
import org.apache.maven.surefire.util.UrlUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.Commandline;

/**
* Configuration for forking tests.
Expand Down Expand Up @@ -160,7 +159,7 @@ public Properties getSystemProperties()
/**
* @param classPath cla the classpath arguments
* @param classpathConfiguration the classpath configuration
* @param shadefire true if running shadefire
* @param shadefire true if running shadefire
* @return A commandline
* @throws org.apache.maven.surefire.booter.SurefireBooterForkException
* when unable to perform the fork
Expand Down Expand Up @@ -221,13 +220,11 @@ public Commandline createCommandLine( List classPath, boolean useJar, boolean sh
}
else
{
cli.createArg().setValue( "-classpath" );

cli.createArg().setValue( StringUtils.join( classPath.iterator(), File.pathSeparator ) );
cli.addEnvironment( "CLASSPATH", StringUtils.join( classPath.iterator(), File.pathSeparator ) );

final String forkedBooter = ForkedBooter.class.getName();

cli.createArg().setValue( shadefire ? new Relocator( ).relocate( forkedBooter ) : forkedBooter);
cli.createArg().setValue( shadefire ? new Relocator().relocate( forkedBooter ) : forkedBooter );
}

cli.setWorkingDirectory( workingDirectory.getAbsolutePath() );
Expand Down
Expand Up @@ -47,6 +47,13 @@ java -classpath foo.jar:bar.jar MyApp
your command line, and therefore a limit on how long you can make your classpath. The limit is different
on different versions of Windows; in some versions only a few hundred characters are allowed, in others
a few thousand, but the limit can be pretty severe in either case.

* Update for Surefire 2.8.2

It turns out setting the CLASSPATH as an environment variable may remove most of the
practical length limitations, as documented in http://jira.codehaus.org/browse/SUREFIRE-727. This means
most of the length-related problems in this article may be outdated.


* How do people solve this problem in general?

Expand Down

0 comments on commit d6e6a84

Please sign in to comment.