mirror of
https://github.com/apache/maven.git
synced 2025-03-08 17:49:15 +00:00
[MNG-7131] maven.config doesn't handle arguments with spaces in them
Since we don't have a clear specification of the file format change reading of the file to a one-arg-per-line basis just like Java's @argfiles or Python's argparse would handle it. Consider that jvm.config suffers from the same issue its parsing is not portable between Bourne shell and Windows Command prompt.
This commit is contained in:
parent
a23ff0f9a2
commit
331c5c3435
@ -32,6 +32,7 @@
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -331,7 +332,7 @@ void cli(CliRequest cliRequest) throws Exception {
|
||||
File configFile = new File(cliRequest.multiModuleProjectDirectory, MVN_MAVEN_CONFIG);
|
||||
|
||||
if (configFile.isFile()) {
|
||||
for (String arg : new String(Files.readAllBytes(configFile.toPath())).split("\\s+")) {
|
||||
for (String arg : Files.readAllLines(configFile.toPath(), Charset.defaultCharset())) {
|
||||
if (!arg.isEmpty()) {
|
||||
args.add(arg);
|
||||
}
|
||||
|
@ -126,8 +126,10 @@ public void testMavenConfigInvalid() throws Exception {
|
||||
/**
|
||||
* Read .mvn/maven.config with the following definitions:
|
||||
* <pre>
|
||||
* -T 3
|
||||
* -T
|
||||
* 3
|
||||
* -Drevision=1.3.0
|
||||
* "-Dlabel=Apache Maven"
|
||||
* </pre>
|
||||
* and check if the {@code -T 3} option can be overwritten via command line
|
||||
* argument.
|
||||
@ -151,8 +153,10 @@ public void testMVNConfigurationThreadCanBeOverwrittenViaCommandLine() throws Ex
|
||||
/**
|
||||
* Read .mvn/maven.config with the following definitions:
|
||||
* <pre>
|
||||
* -T 3
|
||||
* -T
|
||||
* 3
|
||||
* -Drevision=1.3.0
|
||||
* "-Dlabel=Apache Maven"
|
||||
* </pre>
|
||||
* and check if the {@code -Drevision-1.3.0} option can be overwritten via command line
|
||||
* argument.
|
||||
@ -178,8 +182,10 @@ public void testMVNConfigurationDefinedPropertiesCanBeOverwrittenViaCommandLine(
|
||||
/**
|
||||
* Read .mvn/maven.config with the following definitions:
|
||||
* <pre>
|
||||
* -T 3
|
||||
* -T
|
||||
* 3
|
||||
* -Drevision=1.3.0
|
||||
* "-Dlabel=Apache Maven"
|
||||
* </pre>
|
||||
* and check if the {@code -Drevision-1.3.0} option can be overwritten via command line
|
||||
* argument.
|
||||
@ -205,8 +211,10 @@ public void testMVNConfigurationCLIRepeatedPropertiesLastWins() throws Exception
|
||||
/**
|
||||
* Read .mvn/maven.config with the following definitions:
|
||||
* <pre>
|
||||
* -T 3
|
||||
* -T
|
||||
* 3
|
||||
* -Drevision=1.3.0
|
||||
* "-Dlabel=Apache Maven"
|
||||
* </pre>
|
||||
* and check if the {@code -Drevision-1.3.0} option can be overwritten via command line argument when there are
|
||||
* funky arguments present.
|
||||
@ -229,11 +237,14 @@ public void testMVNConfigurationFunkyArguments() throws Exception {
|
||||
cli.cli(request);
|
||||
cli.properties(request);
|
||||
|
||||
assertEquals("3", request.commandLine.getOptionValue(CLIManager.THREADS));
|
||||
|
||||
String revision = System.getProperty("revision");
|
||||
assertEquals("8.2.0", revision);
|
||||
|
||||
assertEquals("bar ", request.getUserProperties().getProperty("foo"));
|
||||
assertEquals("bar two", request.getUserProperties().getProperty("foo2"));
|
||||
assertEquals("Apache Maven", request.getSystemProperties().getProperty("label"));
|
||||
|
||||
assertEquals("-Dpom.xml", request.getCommandLine().getOptionValue(CLIManager.ALTERNATE_POM_FILE));
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
-T8 --builder
|
||||
multithreaded
|
||||
-T8
|
||||
--builder
|
||||
multithreaded
|
||||
|
@ -1,3 +1,5 @@
|
||||
-T 3
|
||||
-T
|
||||
3
|
||||
-Drevision=1.3.0
|
||||
"-Dlabel=Apache Maven"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user