Maven
  1. Maven
  2. MNG-3368

Printing version (-v argument) should not stop lifecycle execution

    Details

    • Number of attachments :
      0

      Description

      I wanted to always print the Maven version when I build, but unfortunately Maven immediately quits after outputting the version. This option should not quit when a lifecycle is also specified. Example: mvn -v install

        Issue Links

          Activity

          Hide
          Paul Benedict added a comment -

          I believe the fix is easy. Two use cases have to be supported:
          1) If --version and no phase specified, then print version and quit. This prevents the "You must specify at least one goal" message.
          2) If --version and phase(s) specified, then print version and continue.

          The change needs to be made in org.apache.maven.cli.MavenCli

          Line 142 has this:
          if ( commandLine.hasOption( CLIManager.VERSION ) )
          {
          showVersion();
          if ( // *** Add second condition )

          { return 0; }

          }

          Show
          Paul Benedict added a comment - I believe the fix is easy. Two use cases have to be supported: 1) If --version and no phase specified, then print version and quit. This prevents the "You must specify at least one goal" message. 2) If --version and phase(s) specified, then print version and continue. The change needs to be made in org.apache.maven.cli.MavenCli Line 142 has this: if ( commandLine.hasOption( CLIManager.VERSION ) ) { showVersion(); if ( // *** Add second condition ) { return 0; } }
          Hide
          Barend Garvelink added a comment - - edited

          The Java VM itself provides the following options:

          -version -----> print product version and exit

          -version:<value> -----> require the specified version to run

          -showversion -----> print product version and continue

          Consider providing the same options in Maven.

          (comment edited: apparently Confluence table syntax isn't supported)

          Show
          Barend Garvelink added a comment - - edited The Java VM itself provides the following options: -version -----> print product version and exit -version:<value> -----> require the specified version to run -showversion -----> print product version and continue Consider providing the same options in Maven. (comment edited: apparently Confluence table syntax isn't supported)
          Hide
          Paul Benedict added a comment -

          I would be satisfied with -showversion, if Maven developers must keep the current semantics of -version

          Show
          Paul Benedict added a comment - I would be satisfied with -showversion, if Maven developers must keep the current semantics of -version
          Hide
          John Casey added a comment -

          New options:

          mvn -V clean
          mvn --show-version clean

          will show the maven, java, etc. versions without stopping the build.

          The original -v option will remain intact and unmodified to keep from causing problems with scripted maven executions, etc.

          Show
          John Casey added a comment - New options: mvn -V clean mvn --show-version clean will show the maven, java, etc. versions without stopping the build. The original -v option will remain intact and unmodified to keep from causing problems with scripted maven executions, etc.
          Hide
          John Casey added a comment -

          Adding fix-for for both 2.0.10 and 2.1.0-M1, since 2.1.0-M1 will actually be released first and may not incorporate all of the eventual issue fixes released in 2.0.10.

          Show
          John Casey added a comment - Adding fix-for for both 2.0.10 and 2.1.0-M1, since 2.1.0-M1 will actually be released first and may not incorporate all of the eventual issue fixes released in 2.0.10.
          Hide
          Benjamin Bentmann added a comment -

          Was reverted from 2.0.x branch in r688884.

          Show
          Benjamin Bentmann added a comment - Was reverted from 2.0.x branch in r688884 .

            People

            • Assignee:
              John Casey
              Reporter:
              Paul Benedict
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: