You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2017/04/01 22:21:36 UTC
[08/28] maven git commit: [MNG-6078] Confirm commons-cli 1.4-SNAPSHOT
before official release
[MNG-6078] Confirm commons-cli 1.4-SNAPSHOT before official release
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/6e499f64
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/6e499f64
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/6e499f64
Branch: refs/heads/MNG-6169
Commit: 6e499f64d5f8d3e826d548592a4c4c9ffcde5246
Parents: 3e63762
Author: rfscholte <rf...@apache.org>
Authored: Wed Mar 8 21:38:08 2017 +0100
Committer: Michael Osipov <mi...@apache.org>
Committed: Sun Apr 2 00:21:12 2017 +0200
----------------------------------------------------------------------
.../java/org/apache/maven/cli/MavenCli.java | 42 ++++++++++-
.../org/apache/maven/cli/MergedCommandLine.java | 75 --------------------
pom.xml | 2 +-
3 files changed, 42 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/6e499f64/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 350fa61..004cf4e 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -23,6 +23,7 @@ import com.google.common.base.Charsets;
import com.google.common.io.Files;
import com.google.inject.AbstractModule;
import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.UnrecognizedOptionException;
import org.apache.maven.BuildAbort;
@@ -463,7 +464,7 @@ public class MavenCli
}
else
{
- cliRequest.commandLine = new MergedCommandLine( cliManager.parse( cliRequest.args ), mavenConfig );
+ cliRequest.commandLine = cliMerge( cliManager.parse( cliRequest.args ), mavenConfig );
}
}
catch ( ParseException e )
@@ -486,6 +487,45 @@ public class MavenCli
}
}
+ 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 );
+ }
+
+ // now add all options, except for -D with cli first then config file
+ List<Option> setPropertyOptions = new ArrayList<>();
+ for ( Option opt : mavenArgs.getOptions() )
+ {
+ if ( String.valueOf( CLIManager.SET_SYSTEM_PROPERTY ).equals( opt.getOpt() ) )
+ {
+ setPropertyOptions.add( opt );
+ }
+ else
+ {
+ commandLineBuilder.addOption( opt );
+ }
+ }
+ for ( Option opt : mavenConfig.getOptions() )
+ {
+ commandLineBuilder.addOption( opt );
+ }
+ // finally add the CLI system properties
+ for ( Option opt : setPropertyOptions )
+ {
+ commandLineBuilder.addOption( opt );
+ }
+ return commandLineBuilder.build();
+ }
+
/**
* configure logging
*/
http://git-wip-us.apache.org/repos/asf/maven/blob/6e499f64/maven-embedder/src/main/java/org/apache/maven/cli/MergedCommandLine.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MergedCommandLine.java b/maven-embedder/src/main/java/org/apache/maven/cli/MergedCommandLine.java
deleted file mode 100644
index cb0a587..0000000
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MergedCommandLine.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.apache.maven.cli;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A {@link CommandLine} instance that represents a merged command line combining CLI arguments with those from the
- * {@code .mvn/maven.config} while reflecting the handling of {@link CLIManager#SET_SYSTEM_PROPERTY} versus all the
- * other command line options (last wins vs first wins respectively).
- */
-class MergedCommandLine
- extends CommandLine
-{
- MergedCommandLine( CommandLine commandLine, CommandLine configFile )
- {
- // such a pity that Commons CLI does not offer either a builder or a formatter and we need to extend
- // to perform the merge. A formatter would mean we could unparse and reparse (not ideal but would work).
- // A builder would be ideal for this kind of merge like processing.
- super();
- // the args are easy, cli first then config file
- for ( String arg : commandLine.getArgs() )
- {
- addArg( arg );
- }
- for ( String arg : configFile.getArgs() )
- {
- addArg( arg );
- }
- // now add all options, except for -D with cli first then config file
- List<Option> setPropertyOptions = new ArrayList<>();
- for ( Option opt : commandLine.getOptions() )
- {
- if ( String.valueOf( CLIManager.SET_SYSTEM_PROPERTY ).equals( opt.getOpt() ) )
- {
- setPropertyOptions.add( opt );
- }
- else
- {
- addOption( opt );
- }
- }
- for ( Option opt : configFile.getOptions() )
- {
- addOption( opt );
- }
- // finally add the CLI system properties
- for ( Option opt : setPropertyOptions )
- {
- addOption( opt );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven/blob/6e499f64/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 44c361a..653471b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@ under the License.
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<classWorldsVersion>2.5.2</classWorldsVersion>
- <commonsCliVersion>1.3.1</commonsCliVersion>
+ <commonsCliVersion>1.4-SNAPSHOT</commonsCliVersion>
<commonsLangVersion>3.5</commonsLangVersion>
<junitVersion>4.12</junitVersion>
<mockitoVersion>1.10.19</mockitoVersion>