Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6790

Redundant code in MavenCli.cliMerge

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Trivial
    • Resolution: Won't Fix
    • 3.6.3
    • None
    • Embedding
    • None

    Description

      cliMerge has a code to append all unrecognized arguments (i.e. goals)
      from maven.config to the resulting CommandLine object:

          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 );
              }
      ...
      

      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:

          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 );
                      }
      ...
      

      Note to the above snippets: CommandLine.getArgs() is almost the same as CommandLine.getArgList() - the only difference is that getArgs() returns String[] while getArgList() returns List<String>.

      Attachments

        Issue Links

          Activity

            People

              rfscholte Robert Scholte
              anatoly.zaretsky Anatoly Zaretsky
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m