mthmulders commented on a change in pull request #605:
URL: https://github.com/apache/maven/pull/605#discussion_r742015667
##########
File path: maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
##########
@@ -1730,18 +1731,15 @@ static void populateProperties( CommandLine
commandLine, Properties systemProper
// are most dominant.
//
----------------------------------------------------------------------
- if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) )
- {
- String[] defStrs = commandLine.getOptionValues(
CLIManager.SET_SYSTEM_PROPERTY );
-
- if ( defStrs != null )
- {
- for ( String defStr : defStrs )
+ Arrays.stream( commandLine.getOptions() )
+ .filter( option -> CLIManager.SET_SYSTEM_PROPERTY ==
option.getOpt().charAt( 0 ) )
+ .map( option -> option.getValues() )
+ .forEach( values ->
{
- setCliProperty( defStr, userProperties );
- }
- }
- }
+ final String key = values[0].trim();
Review comment:
In the old situation, we used to do `cli.getOptionValue("-D")`. Given
arguments `"-Dx=1 -Dy -Dz=2"`, we would get `["x=1", "y", "z=2"]`. That's why
we did a `.split("=")` to separate the key from the value.
In the new situation, we do `cli.getOptions()`, then filter out those that
represent a "-D". Given arguments `"-Dx=1 -Dy -Dz=2"`, we would get **three**
`Option` instances:
1. where `getValues()` returns `["x", "1"]`
2. where `getValues()` returns `["y"]`
3. where `getValues()` returns `["z", "2"]`
This way we don't have to do magic with indices in the array anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]