From d6e6a843834516cee5adc7cd2ba0066425371cd1 Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Tue, 19 Apr 2011 19:25:58 +0000 Subject: [PATCH] [SUREFIRE-727] Classpath too long on windows with useManifestOnlyJar=false git-svn-id: https://svn.apache.org/repos/asf/maven/surefire/trunk@1095173 13f79535-47bb-0310-9956-ffa450edef68 --- .../site/apt/examples/class-loading.apt.vm | 8 +++++- .../booterclient/ForkConfiguration.java | 25 ++++++++----------- .../site/apt/examples/class-loading.apt.vm | 7 ++++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/maven-failsafe-plugin/src/site/apt/examples/class-loading.apt.vm b/maven-failsafe-plugin/src/site/apt/examples/class-loading.apt.vm index b3dd5174b8..ff1c6b8d0f 100644 --- a/maven-failsafe-plugin/src/site/apt/examples/class-loading.apt.vm +++ b/maven-failsafe-plugin/src/site/apt/examples/class-loading.apt.vm @@ -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. diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java index 4550cd9f14..9e5c2a4092 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java @@ -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; @@ -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. @@ -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 @@ -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() ); diff --git a/maven-surefire-plugin/src/site/apt/examples/class-loading.apt.vm b/maven-surefire-plugin/src/site/apt/examples/class-loading.apt.vm index 1d97d7fa35..1eecf721d9 100644 --- a/maven-surefire-plugin/src/site/apt/examples/class-loading.apt.vm +++ b/maven-surefire-plugin/src/site/apt/examples/class-loading.apt.vm @@ -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?