[
https://issues.apache.org/jira/browse/MNG-6790?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Robert Scholte closed MNG-6790.
-------------------------------
Assignee: Robert Scholte
Resolution: Won't Fix
At the moment cliMerge is only used once, and because of that your conclusion
is correct.
However, in concept having a method like {{T merge(T lhs, T rhs)}} means that
all elements from both lhr and rhs should be combines, you should not do any
assumptions.
The new assert is nearly as expensive as a foreach over an empty list, so I
don't see the benefit of this change and will close it.
> Redundant code in MavenCli.cliMerge
> -----------------------------------
>
> Key: MNG-6790
> URL: https://issues.apache.org/jira/browse/MNG-6790
> Project: Maven
> Issue Type: Task
> Components: Embedding
> Affects Versions: 3.6.3
> Reporter: Anatoly Zaretsky
> Assignee: Robert Scholte
> Priority: Trivial
> Time Spent: 10m
> Remaining Estimate: 0h
>
> cliMerge has a code to append all unrecognized arguments (i.e. goals)
> from maven.config to the resulting CommandLine object:
> {code}
> private CommandLine cliMerge( CommandLine mavenArgs, CommandLine
> mavenConfig )
> {
> CommandLine.Builder commandLineBuilder = new CommandLine.Builder();
> // the args are easy, cli first then config file
> for ( String arg : mavenArgs.getArgs() )
> {
> commandLineBuilder.addArg( arg );
> }
> for ( String arg : mavenConfig.getArgs() )
> {
> commandLineBuilder.addArg( arg );
> }
> ...
> {code}
> But this code always does nothing since the result of maven.config parsing is
> checked
> for absence of any such unrecognized arguments right before the merging
> is performed:
> {code} void cli( CliRequest cliRequest )
> throws Exception
> {
> ...
> mavenConfig = cliManager.parse( args.toArray( new String[0] )
> );
> List<?> unrecongized = mavenConfig.getArgList();
> if ( !unrecongized.isEmpty() )
> {
> throw new ParseException( "Unrecognized maven.config
> entries: " + unrecongized );
> }
> ...
> {code}
> Note to the above snippets:
> [CommandLine.getArgs()|https://commons.apache.org/proper/commons-cli/javadocs/api-release/org/apache/commons/cli/CommandLine.html#getArgs--]
> is almost the same as
> [CommandLine.getArgList()|https://commons.apache.org/proper/commons-cli/javadocs/api-release/org/apache/commons/cli/CommandLine.html#getArgList--]
> - the only difference is that getArgs() returns String[] while getArgList()
> returns List<String>.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)