|
24 | 24 | * SOFTWARE.
|
25 | 25 | */
|
26 | 26 |
|
27 |
| -import org.codehaus.plexus.compiler.AbstractCompilerTest; |
28 |
| -import org.codehaus.plexus.compiler.CompilerConfiguration; |
29 |
| -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; |
30 |
| -import org.apache.maven.artifact.repository.DefaultArtifactRepository; |
31 |
| -import org.apache.maven.artifact.repository.ArtifactRepository; |
32 |
| -import org.apache.maven.artifact.Artifact; |
33 |
| -import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; |
34 |
| -import org.apache.maven.settings.Settings; |
35 |
| -import org.apache.maven.model.Repository; |
36 |
| - |
37 | 27 | import java.io.File;
|
38 | 28 | import java.io.FileReader;
|
39 | 29 | import java.util.ArrayList;
|
40 | 30 | import java.util.LinkedHashMap;
|
41 | 31 | import java.util.List;
|
42 | 32 |
|
| 33 | +import org.apache.maven.artifact.Artifact; |
| 34 | +import org.apache.maven.artifact.repository.ArtifactRepository; |
| 35 | +import org.apache.maven.artifact.repository.DefaultArtifactRepository; |
| 36 | +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; |
| 37 | +import org.apache.maven.settings.Settings; |
| 38 | +import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; |
| 39 | +import org.codehaus.plexus.compiler.AbstractCompilerTest; |
| 40 | +import org.codehaus.plexus.compiler.CompilerConfiguration; |
| 41 | + |
43 | 42 | /**
|
44 | 43 | * @author <a href="mailto:jason@plexus.org">Jason van Zyl</a>
|
45 | 44 | * @version $Id$
|
@@ -163,6 +162,39 @@ public void testBuildCompilerArgsUnspecifiedVersion()
|
163 | 162 | internalTest( compilerConfiguration, expectedArguments );
|
164 | 163 | }
|
165 | 164 |
|
| 165 | + public void testCommandLineTooLongWhenForking() |
| 166 | + throws Exception |
| 167 | + { |
| 168 | + List expectedArguments = new ArrayList(); |
| 169 | + |
| 170 | + CompilerConfiguration compilerConfiguration = new CompilerConfiguration(); |
| 171 | + |
| 172 | + populateArguments( compilerConfiguration, expectedArguments, false, false ); |
| 173 | + |
| 174 | + compilerConfiguration.setFork( true ); |
| 175 | + |
| 176 | + internalTest( compilerConfiguration, expectedArguments ); |
| 177 | + |
| 178 | + JavacCompiler compiler = (JavacCompiler) lookup( org.codehaus.plexus.compiler.Compiler.ROLE, getRoleHint() ); |
| 179 | + |
| 180 | + File destDir = new File( "target/test-classes-cmd" ); |
| 181 | + destDir.mkdirs(); |
| 182 | + |
| 183 | + /* fill the cmd line arguments, 300 is enough to make it break */ |
| 184 | + String[] args = new String[400]; |
| 185 | + args[0] = "-d"; |
| 186 | + args[1] = destDir.getAbsolutePath(); |
| 187 | + for ( int i = 2; i < args.length; i++ ) |
| 188 | + { |
| 189 | + args[i] = "org/codehaus/foo/Person.java"; |
| 190 | + } |
| 191 | + |
| 192 | + List messages = compiler.compileOutOfProcess( new File( getBasedir() + "/src/test-input/src/main" ), "javac", |
| 193 | + args ); |
| 194 | + |
| 195 | + assertEquals( "There were errors launching the external compiler: " + messages, 0, messages.size() ); |
| 196 | + } |
| 197 | + |
166 | 198 | private void populateArguments( CompilerConfiguration compilerConfiguration, List expectedArguments,
|
167 | 199 | boolean suppressSourceVersion, boolean suppressEncoding )
|
168 | 200 | {
|
|
0 commit comments