[Created] (MNG-6790) Redundant code in MavenCli.cliMerge

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Created] (MNG-6790) Redundant code in MavenCli.cliMerge

Hudson (Jira)
Anatoly Zaretsky created MNG-6790:
-------------------------------------

             Summary: 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


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)