Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,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;
Expand Down Expand Up @@ -387,7 +388,7 @@ void cli( CliRequest cliRequest )

if ( configFile.isFile() )
{
for ( String arg : new String( Files.readAllBytes( configFile.toPath() ) ).split( "\\s+" ) )
for ( String arg : Files.readAllLines( configFile.toPath(), Charset.defaultCharset() ) )
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I have retained the original file encoding because jvm.config is subject to the same platform encoding. We can consider making maven.config UTF-8 only.

{
if ( !arg.isEmpty() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ public void testMavenConfigInvalid()
/**
* 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.
Expand All @@ -221,8 +223,10 @@ public void testMVNConfigurationThreadCanBeOverwrittenViaCommandLine()
/**
* 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.
Expand All @@ -249,8 +253,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.
Expand All @@ -277,8 +283,10 @@ public void testMVNConfigurationCLIRepeatedPropertiesLastWins()
/**
* 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.
Expand All @@ -300,11 +308,14 @@ public void testMVNConfigurationFunkyArguments()
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.getSystemProperties().getProperty( "foo" ) );
assertEquals( "bar two", request.getSystemProperties().getProperty( "foo2" ) );
assertEquals( "Apache Maven", request.getSystemProperties().getProperty( "label" ) );

assertEquals( "-Dpom.xml", request.getCommandLine().getOptionValue( CLIManager.ALTERNATE_POM_FILE ) );
}
Expand Down
5 changes: 3 additions & 2 deletions maven-embedder/src/test/projects/config/.mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-T8 --builder
multithreaded
-T8
--builder
multithreaded
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-T 3
-T
3
-Drevision=1.3.0
"-Dlabel=Apache Maven"