[ https://issues.apache.org/jira/browse/MNG-6790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16985442#comment-16985442 ]
Anatoly Zaretsky commented on MNG-6790: --------------------------------------- Thanks for clarification - since {{cliMerge}} is private, I initially thought it was just a one-shot helper to reduce the size of {{cli}}. As to the expensiveness of the assert I am not sure I follow. If by being expensive you mean having an execution overhead, then please note, that assertions are costless unless explicitly enabled at run time, e.g. by adding "-ea" to MAVEN_OPTS. > 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: 20m > 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)