You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2018/10/20 12:29:37 UTC
[maven] branch slach-pre-merge-master updated (5037d37 -> e21885b)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch slach-pre-merge-master
in repository https://gitbox.apache.org/repos/asf/maven.git.
discard 5037d37 [MNG-6492] - Minor improvement on Array construction, conversion performance
add 23f5c88 [MNG-6391] - Printout version of last built module in reactor build
new 936b055 [MNG-6492] - Minor improvement on Array construction, conversion performance
new 98221fd [MNG-6069] Migrate to non deprecated parts of Commons CLI
new e21885b [MNG-5995] Remove dependency to maven-compat
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (5037d37)
\
N -- N -- N refs/heads/slach-pre-merge-master (e21885b)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/maven/bridge/MavenRepositorySystem.java | 93 +++++++++++++++-
.../project/DefaultProjectBuildingHelper.java | 6 +-
.../main/java/org/apache/maven/cli/CLIManager.java | 120 +++++++++++----------
.../main/java/org/apache/maven/cli/MavenCli.java | 49 ++-------
.../maven/cli/event/ExecutionEventLogger.java | 38 +++++--
5 files changed, 198 insertions(+), 108 deletions(-)
[maven] 03/03: [MNG-5995] Remove dependency to maven-compat
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch slach-pre-merge-master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit e21885b67760c1d5ac54c0485efbe6bd908c3290
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Oct 13 04:16:44 2018 +0200
[MNG-5995] Remove dependency to maven-compat
---
.../apache/maven/bridge/MavenRepositorySystem.java | 93 +++++++++++++++++++++-
.../project/DefaultProjectBuildingHelper.java | 6 +-
2 files changed, 94 insertions(+), 5 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
index 84ad93c..07ffdae 100644
--- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
+++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
@@ -23,8 +23,10 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -606,8 +608,95 @@ public class MavenRepositorySystem
return repoIds;
}
-
-
+
+ public List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository> repositories )
+ {
+ if ( repositories == null )
+ {
+ return null;
+ }
+
+ Map<String, List<ArtifactRepository>> reposByKey = new LinkedHashMap<>();
+
+ for ( ArtifactRepository repository : repositories )
+ {
+ String key = repository.getId();
+
+ List<ArtifactRepository> aliasedRepos = reposByKey.get( key );
+
+ if ( aliasedRepos == null )
+ {
+ aliasedRepos = new ArrayList<>();
+ reposByKey.put( key, aliasedRepos );
+ }
+
+ aliasedRepos.add( repository );
+ }
+
+ List<ArtifactRepository> effectiveRepositories = new ArrayList<>();
+
+ for ( List<ArtifactRepository> aliasedRepos : reposByKey.values() )
+ {
+ List<ArtifactRepository> mirroredRepos = new ArrayList<>();
+
+ List<ArtifactRepositoryPolicy> releasePolicies =
+ new ArrayList<>( aliasedRepos.size() );
+
+ for ( ArtifactRepository aliasedRepo : aliasedRepos )
+ {
+ releasePolicies.add( aliasedRepo.getReleases() );
+ mirroredRepos.addAll( aliasedRepo.getMirroredRepositories() );
+ }
+
+ ArtifactRepositoryPolicy releasePolicy = getEffectivePolicy( releasePolicies );
+
+ List<ArtifactRepositoryPolicy> snapshotPolicies =
+ new ArrayList<>( aliasedRepos.size() );
+
+ for ( ArtifactRepository aliasedRepo : aliasedRepos )
+ {
+ snapshotPolicies.add( aliasedRepo.getSnapshots() );
+ }
+
+ ArtifactRepositoryPolicy snapshotPolicy = getEffectivePolicy( snapshotPolicies );
+
+ ArtifactRepository aliasedRepo = aliasedRepos.get( 0 );
+
+ ArtifactRepository effectiveRepository =
+ createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(),
+ snapshotPolicy, releasePolicy );
+
+ effectiveRepository.setAuthentication( aliasedRepo.getAuthentication() );
+
+ effectiveRepository.setProxy( aliasedRepo.getProxy() );
+
+ effectiveRepository.setMirroredRepositories( mirroredRepos );
+
+ effectiveRepositories.add( effectiveRepository );
+ }
+
+ return effectiveRepositories;
+ }
+
+ private ArtifactRepositoryPolicy getEffectivePolicy( Collection<ArtifactRepositoryPolicy> policies )
+ {
+ ArtifactRepositoryPolicy effectivePolicy = null;
+
+ for ( ArtifactRepositoryPolicy policy : policies )
+ {
+ if ( effectivePolicy == null )
+ {
+ effectivePolicy = new ArtifactRepositoryPolicy( policy );
+ }
+ else
+ {
+ effectivePolicy.merge( policy );
+ }
+ }
+
+ return effectivePolicy;
+ }
+
public ArtifactRepository createLocalRepository( MavenExecutionRequest request, File localRepository )
throws Exception
{
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
index 3159fac..0bd94a8 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
@@ -33,6 +33,7 @@ import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.bridge.MavenRepositorySystem;
import org.apache.maven.classrealm.ClassRealmManager;
import org.apache.maven.model.Build;
import org.apache.maven.model.Extension;
@@ -44,7 +45,6 @@ import org.apache.maven.plugin.MavenPluginManager;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginResolutionException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
-import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
@@ -78,7 +78,7 @@ public class DefaultProjectBuildingHelper
private ProjectRealmCache projectRealmCache;
@Requirement
- private RepositorySystem repositorySystem;
+ private MavenRepositorySystem repositorySystem;
@Requirement
private MavenPluginManager pluginManager;
@@ -92,7 +92,7 @@ public class DefaultProjectBuildingHelper
for ( Repository repository : pomRepositories )
{
- internalRepositories.add( repositorySystem.buildArtifactRepository( repository ) );
+ internalRepositories.add( MavenRepositorySystem.buildArtifactRepository( repository ) );
}
repositorySystem.injectMirror( request.getRepositorySession(), internalRepositories );
[maven] 01/03: [MNG-6492] - Minor improvement on Array construction,
conversion performance
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch slach-pre-merge-master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 936b0559dba65d83be32fdd69861dfc51ce2a508
Author: HoaPhan <ho...@atlassian.com>
AuthorDate: Sat Sep 8 22:46:22 2018 +1000
[MNG-6492] - Minor improvement on Array construction, conversion performance
Fixes #186
---
maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java | 6 +-----
.../maven/repository/metadata/DefaultClasspathTransformation.java | 2 +-
.../main/java/org/apache/maven/project/ProjectModelResolver.java | 5 ++---
.../org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java | 2 +-
.../org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java | 5 +----
.../src/main/java/org/apache/maven/cli/CleanArgument.java | 2 +-
maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java | 4 ++--
.../maven/model/interpolation/StringSearchModelInterpolator.java | 3 +--
.../org/apache/maven/repository/internal/DefaultModelResolver.java | 4 +---
9 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java b/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java
index fb99593..9bcc384 100644
--- a/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java
+++ b/maven-compat/src/main/java/org/apache/maven/project/ModelUtils.java
@@ -313,12 +313,8 @@ public final class ModelUtils
public static List<Repository> mergeRepositoryLists( List<Repository> dominant, List<Repository> recessive )
{
- List<Repository> repositories = new ArrayList<>();
- for ( Repository repository : dominant )
- {
- repositories.add( repository );
- }
+ List<Repository> repositories = new ArrayList<>( dominant );
for ( Repository repository : recessive )
{
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java
index b6e3c0c..f980f5a 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/metadata/DefaultClasspathTransformation.java
@@ -139,7 +139,7 @@ public class DefaultClasspathTransformation
if ( exits != null && exits.size() > 0 )
{
- MetadataGraphEdge[] sortedExits = exits.toArray( new MetadataGraphEdge[exits.size()] );
+ MetadataGraphEdge[] sortedExits = exits.toArray( new MetadataGraphEdge[0] );
Arrays.sort( sortedExits
,
new Comparator<MetadataGraphEdge>()
diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
index 2b3108a..24b36dd 100644
--- a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
@@ -49,6 +49,7 @@ import org.eclipse.aether.resolution.VersionRangeRequest;
import org.eclipse.aether.resolution.VersionRangeResolutionException;
import org.eclipse.aether.resolution.VersionRangeResult;
+
/**
* A model resolver to assist building of projects. This resolver gives priority to those repositories that have been
* declared in the POM.
@@ -91,9 +92,7 @@ public class ProjectModelResolver
this.resolver = resolver;
this.remoteRepositoryManager = remoteRepositoryManager;
this.pomRepositories = new ArrayList<>();
- List<RemoteRepository> externalRepositories = new ArrayList<>();
- externalRepositories.addAll( repositories );
- this.externalRepositories = Collections.unmodifiableList( externalRepositories );
+ this.externalRepositories = Collections.unmodifiableList( new ArrayList<>( repositories ) );
this.repositories = new ArrayList<>();
this.repositories.addAll( externalRepositories );
this.repositoryMerging = repositoryMerging;
diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java
index 40db389..1591573 100644
--- a/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java
+++ b/maven-core/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java
@@ -69,7 +69,7 @@ public class DefaultToolchainManagerPrivate
}
}
- return toRet.toArray( new ToolchainPrivate[toRet.size()] );
+ return toRet.toArray( new ToolchainPrivate[0] );
}
@Override
diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java
index a8572ff..8a6580b 100644
--- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java
+++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/MojoExecutorStub.java
@@ -50,10 +50,7 @@ public class MojoExecutorStub
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
throws LifecycleExecutionException
{
- for ( MojoExecution mojoExecution : mojoExecutions )
- {
- executions.add( mojoExecution );
- }
+ executions.addAll(mojoExecutions);
}
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java b/maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java
index 8b2d9b7..08403b6 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CleanArgument.java
@@ -115,7 +115,7 @@ public class CleanArgument
}
else
{
- cleanArgs = cleaned.toArray( new String[cleanedSz] );
+ cleanArgs = cleaned.toArray( new String[0] );
}
return cleanArgs;
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 6a1a34a..f7ceda2 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
@@ -384,7 +384,7 @@ public class MavenCli
}
}
- mavenConfig = cliManager.parse( args.toArray( new String[args.size()] ) );
+ mavenConfig = cliManager.parse( args.toArray( new String[0] ) );
List<?> unrecongized = mavenConfig.getArgList();
if ( !unrecongized.isEmpty() )
{
@@ -1196,7 +1196,7 @@ public class MavenCli
sb.append( String.format( "%s\n", configurationProcessor.getClass().getName() ) );
}
}
- sb.append( String.format( "\n" ) );
+ sb.append( "\n" );
throw new Exception( sb.toString() );
}
}
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
index c95cacb..25982cd 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java
@@ -263,9 +263,8 @@ public class StringSearchModelInterpolator
fields.add( new ObjectField( currentField ) );
}
}
-
}
- this.fields = fields.toArray( new CacheField[fields.size()] );
+ this.fields = fields.toArray( new CacheField[0] );
}
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
index 6818453..338f4ff 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
+++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultModelResolver.java
@@ -89,9 +89,7 @@ class DefaultModelResolver
this.versionRangeResolver = versionRangeResolver;
this.remoteRepositoryManager = remoteRepositoryManager;
this.repositories = repositories;
- List<RemoteRepository> externalRepositories = new ArrayList<>();
- externalRepositories.addAll( repositories );
- this.externalRepositories = Collections.unmodifiableList( externalRepositories );
+ this.externalRepositories = Collections.unmodifiableList( new ArrayList<>( repositories ) );
this.repositoryIds = new HashSet<>();
}
[maven] 02/03: [MNG-6069] Migrate to non deprecated parts of
Commons CLI
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch slach-pre-merge-master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 98221fd8fa058e1518f07a59bc28444dd5be8380
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Mon Oct 15 00:51:06 2018 +0200
[MNG-6069] Migrate to non deprecated parts of Commons CLI
Default help line width changed to 120 chars
---
.../main/java/org/apache/maven/cli/CLIManager.java | 120 +++++++++++----------
.../main/java/org/apache/maven/cli/MavenCli.java | 49 ++-------
2 files changed, 72 insertions(+), 97 deletions(-)
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
index a9038bf..12078c6 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
@@ -24,9 +24,9 @@ import java.io.PrintWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
@@ -35,43 +35,43 @@ import org.apache.commons.cli.ParseException;
*/
public class CLIManager
{
- public static final char ALTERNATE_POM_FILE = 'f';
+ public static final String ALTERNATE_POM_FILE = "f";
- public static final char BATCH_MODE = 'B';
+ public static final String BATCH_MODE = "B";
- public static final char SET_SYSTEM_PROPERTY = 'D';
+ public static final String SET_SYSTEM_PROPERTY = "D";
- public static final char OFFLINE = 'o';
+ public static final String OFFLINE = "o";
- public static final char QUIET = 'q';
+ public static final String QUIET = "q";
- public static final char DEBUG = 'X';
+ public static final String DEBUG = "X";
- public static final char ERRORS = 'e';
+ public static final String ERRORS = "e";
- public static final char HELP = 'h';
+ public static final String HELP = "h";
- public static final char VERSION = 'v';
+ public static final String VERSION = "v";
- public static final char SHOW_VERSION = 'V';
+ public static final String SHOW_VERSION = "V";
- public static final char NON_RECURSIVE = 'N';
+ public static final String NON_RECURSIVE = "N";
- public static final char UPDATE_SNAPSHOTS = 'U';
+ public static final String UPDATE_SNAPSHOTS = "U";
- public static final char ACTIVATE_PROFILES = 'P';
+ public static final String ACTIVATE_PROFILES = "P";
public static final String SUPRESS_SNAPSHOT_UPDATES = "nsu";
- public static final char CHECKSUM_FAILURE_POLICY = 'C';
+ public static final String CHECKSUM_FAILURE_POLICY = "C";
- public static final char CHECKSUM_WARNING_POLICY = 'c';
+ public static final String CHECKSUM_WARNING_POLICY = "c";
- public static final char ALTERNATE_USER_SETTINGS = 's';
+ public static final String ALTERNATE_USER_SETTINGS = "s";
public static final String ALTERNATE_GLOBAL_SETTINGS = "gs";
- public static final char ALTERNATE_USER_TOOLCHAINS = 't';
+ public static final String ALTERNATE_USER_TOOLCHAINS = "t";
public static final String ALTERNATE_GLOBAL_TOOLCHAINS = "gt";
@@ -103,50 +103,52 @@ public class CLIManager
protected Options options;
- @SuppressWarnings( { "static-access", "checkstyle:linelength" } )
+ // CHECKSTYLE_OFF: LineLength
public CLIManager()
{
options = new Options();
- options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
- options.addOption( OptionBuilder.withLongOpt( "file" ).hasArg().withDescription( "Force the use of an alternate POM file (or directory with pom.xml)" ).create( ALTERNATE_POM_FILE ) );
- options.addOption( OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create( SET_SYSTEM_PROPERTY ) );
- options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) );
- options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create( VERSION ) );
- options.addOption( OptionBuilder.withLongOpt( "quiet" ).withDescription( "Quiet output - only show errors" ).create( QUIET ) );
- options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create( DEBUG ) );
- options.addOption( OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create( ERRORS ) );
- options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription( "Do not recurse into sub-projects" ).create( NON_RECURSIVE ) );
- options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription( "Forces a check for missing releases and updated snapshots on remote repositories" ).create( UPDATE_SNAPSHOTS ) );
- options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription( "Comma-delimited list of profiles to activate" ).hasArg().create( ACTIVATE_PROFILES ) );
- options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription( "Run in non-interactive (batch) mode (disables output color)" ).create( BATCH_MODE ) );
- options.addOption( OptionBuilder.withLongOpt( "no-snapshot-updates" ).withDescription( "Suppress SNAPSHOT updates" ).create( SUPRESS_SNAPSHOT_UPDATES ) );
- options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription( "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
- options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( CHECKSUM_WARNING_POLICY ) );
- options.addOption( OptionBuilder.withLongOpt( "settings" ).withDescription( "Alternate path for the user settings file" ).hasArg().create( ALTERNATE_USER_SETTINGS ) );
- options.addOption( OptionBuilder.withLongOpt( "global-settings" ).withDescription( "Alternate path for the global settings file" ).hasArg().create( ALTERNATE_GLOBAL_SETTINGS ) );
- options.addOption( OptionBuilder.withLongOpt( "toolchains" ).withDescription( "Alternate path for the user toolchains file" ).hasArg().create( ALTERNATE_USER_TOOLCHAINS ) );
- options.addOption( OptionBuilder.withLongOpt( "global-toolchains" ).withDescription( "Alternate path for the global toolchains file" ).hasArg().create( ALTERNATE_GLOBAL_TOOLCHAINS ) );
- options.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription( "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) );
- options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription( "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) );
- options.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription( "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) );
- options.addOption( OptionBuilder.withLongOpt( "resume-from" ).hasArg().withDescription( "Resume reactor from specified project" ).create( RESUME_FROM ) );
- options.addOption( OptionBuilder.withLongOpt( "projects" ).withDescription( "Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path" ).hasArg().create( PROJECT_LIST ) );
- options.addOption( OptionBuilder.withLongOpt( "also-make" ).withDescription( "If project list is specified, also build projects required by the list" ).create( ALSO_MAKE ) );
- options.addOption( OptionBuilder.withLongOpt( "also-make-dependents" ).withDescription( "If project list is specified, also build projects that depend on projects on the list" ).create( ALSO_MAKE_DEPENDENTS ) );
- options.addOption( OptionBuilder.withLongOpt( "log-file" ).hasArg().withDescription( "Log file where all build output will go (disables output color)" ).create( LOG_FILE ) );
- options.addOption( OptionBuilder.withLongOpt( "show-version" ).withDescription( "Display version information WITHOUT stopping build" ).create( SHOW_VERSION ) );
- options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ).hasOptionalArg().withDescription( "Encrypt master security password" ).create( ENCRYPT_MASTER_PASSWORD ) );
- options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ).hasOptionalArg().withDescription( "Encrypt server password" ).create( ENCRYPT_PASSWORD ) );
- options.addOption( OptionBuilder.withLongOpt( "threads" ).hasArg().withDescription( "Thread count, for instance 2.0C where C is core multiplied" ).create( THREADS ) );
- options.addOption( OptionBuilder.withLongOpt( "legacy-local-repository" ).withDescription( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).create( LEGACY_LOCAL_REPOSITORY ) );
- options.addOption( OptionBuilder.withLongOpt( "builder" ).hasArg().withDescription( "The id of the build strategy to use" ).create( BUILDER ) );
+ options.addOption( Option.builder( HELP ).longOpt( "help" ).desc( "Display help information" ).build() );
+ options.addOption( Option.builder( ALTERNATE_POM_FILE ).longOpt( "file" ).hasArg().desc( "Force the use of an alternate POM file (or directory with pom.xml)" ).build() );
+ options.addOption( Option.builder( SET_SYSTEM_PROPERTY ).longOpt( "define" ).hasArgs().valueSeparator().desc( "Define a system property" ).build() );
+ options.addOption( Option.builder( OFFLINE ).longOpt( "offline" ).desc( "Work offline" ).build() );
+ options.addOption( Option.builder( VERSION ).longOpt( "version" ).desc( "Display version information" ).build() );
+ options.addOption( Option.builder( QUIET ).longOpt( "quiet" ).desc( "Quiet output - only show errors" ).build() );
+ options.addOption( Option.builder( DEBUG ).longOpt( "debug" ).desc( "Produce execution debug output" ).build() );
+ options.addOption( Option.builder( ERRORS ).longOpt( "errors" ).desc( "Produce execution error messages" ).build() );
+ options.addOption( Option.builder( NON_RECURSIVE ).longOpt( "non-recursive" ).desc( "Do not recurse into sub-projects" ).build() );
+ options.addOption( Option.builder( UPDATE_SNAPSHOTS ).longOpt( "update-snapshots" ).desc( "Forces a check for missing releases and updated snapshots on remote repositories" ).build() );
+ options.addOption( Option.builder( ACTIVATE_PROFILES ).longOpt( "activate-profiles" ).desc( "Comma-delimited list of profiles to activate" ).hasArg().build() );
+ options.addOption( Option.builder( BATCH_MODE ).longOpt( "batch-mode" ).desc( "Run in non-interactive (batch) mode (disables output color)" ).build() );
+ options.addOption( Option.builder( SUPRESS_SNAPSHOT_UPDATES ).longOpt( "no-snapshot-updates" ).desc( "Suppress SNAPSHOT updates" ).build() );
+ options.addOption( Option.builder( CHECKSUM_FAILURE_POLICY ).longOpt( "strict-checksums" ).desc( "Fail the build if checksums don't match" ).build() );
+ options.addOption( Option.builder( CHECKSUM_WARNING_POLICY ).longOpt( "lax-checksums" ).desc( "Warn if checksums don't match" ).build() );
+ options.addOption( Option.builder( ALTERNATE_USER_SETTINGS ).longOpt( "settings" ).hasArg().desc( "Alternate path for the user settings file" ).build() );
+ options.addOption( Option.builder( ALTERNATE_GLOBAL_SETTINGS ).longOpt( "global-settings" ).hasArg().desc( "Alternate path for the global settings file" ).build() );
+ options.addOption( Option.builder( ALTERNATE_USER_TOOLCHAINS ).longOpt( "toolchains" ).hasArg().desc( "Alternate path for the user toolchains file" ).hasArg().build() );
+ options.addOption( Option.builder( ALTERNATE_GLOBAL_TOOLCHAINS ).longOpt( "global-toolchains" ).desc( "Alternate path for the global toolchains file" ).hasArg().build() );
+ options.addOption( Option.builder( FAIL_FAST ).longOpt( "fail-fast" ).desc( "Stop at first failure in reactorized builds" ).build() );
+ options.addOption( Option.builder( FAIL_AT_END ).longOpt( "fail-at-end" ).desc( "Only fail the build afterwards; allow all non-impacted builds to continue" ).build() );
+ options.addOption( Option.builder( FAIL_NEVER ).longOpt( "fail-never" ).desc( "NEVER fail the build, regardless of project result" ).build() );
+ options.addOption( Option.builder( RESUME_FROM ).longOpt( "resume-from" ).hasArg().desc( "Resume reactor from specified project" ).build() );
+ options.addOption( Option.builder( PROJECT_LIST ).longOpt( "projects" ).desc( "Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path." ).hasArg().build() );
+ options.addOption( Option.builder( ALSO_MAKE ).longOpt( "also-make" ).desc( "If project list is specified, also build projects required by the list" ).build() );
+ options.addOption( Option.builder( ALSO_MAKE_DEPENDENTS ).longOpt( "also-make-dependents" ).desc( "If project list is specified, also build projects that depend on projects on the list" ).build() );
+ options.addOption( Option.builder( LOG_FILE ).longOpt( "log-file" ).hasArg().desc( "Log file where all build output will go" ).build() );
+ options.addOption( Option.builder( SHOW_VERSION ).longOpt( "show-version" ).desc( "Display version information WITHOUT stopping build" ).build() );
+ options.addOption( Option.builder( ENCRYPT_MASTER_PASSWORD ).longOpt( "encrypt-master-password" ).hasArg().optionalArg( true ).desc( "Encrypt master security password" ).build() );
+ options.addOption( Option.builder( ENCRYPT_PASSWORD ).longOpt( "encrypt-password" ).hasArg().optionalArg( true ).desc( "Encrypt server password" ).build() );
+ options.addOption( Option.builder( THREADS ).longOpt( "threads" ).hasArg().desc( "Thread count, for instance 2.0C where C is core multiplied" ).build() );
+ options.addOption( Option.builder( LEGACY_LOCAL_REPOSITORY ).longOpt( "legacy-local-repository" ).desc( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).build() );
+ options.addOption( Option.builder( BUILDER ).longOpt( "builder" ).hasArg().desc( "The id of the build strategy to use" ).build() );
// Adding this back in for compatibility with the verifier that hard codes this option.
- options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npr" ) );
- options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "cpu" ) );
- options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "up" ) );
- options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npu" ) );
+ options.addOption( Option.builder( "npr" ).longOpt( "no-plugin-registry" ).desc( "Ineffective, only kept for backward compatibility" ).build() );
+ options.addOption( Option.builder( "cpu" ).longOpt( "check-plugin-updates" ).desc( "Ineffective, only kept for backward compatibility" ).build() );
+ options.addOption( Option.builder( "up" ).longOpt( "update-plugins" ).desc( "Ineffective, only kept for backward compatibility" ).build() );
+ options.addOption( Option.builder( "npu" ).longOpt( "no-plugin-updates" ).desc( "Ineffective, only kept for backward compatibility" ).build() );
+
}
+ // CHECKSTYLE_ON: LineLength
public CommandLine parse( String[] args )
throws ParseException
@@ -154,7 +156,7 @@ public class CLIManager
// We need to eat any quotes surrounding arguments...
String[] cleanArgs = CleanArgument.cleanArgs( args );
- CommandLineParser parser = new GnuParser();
+ CommandLineParser parser = new DefaultParser();
return parser.parse( options, cleanArgs );
}
@@ -167,7 +169,7 @@ public class CLIManager
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( pw, HelpFormatter.DEFAULT_WIDTH, "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:",
+ formatter.printHelp( pw, 120, "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:",
options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "\n", false );
pw.flush();
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 f7ceda2..8ea9ba8 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
@@ -1650,14 +1650,18 @@ public class MavenCli
if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) )
{
- String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY );
-
- if ( defStrs != null )
+ Properties lineOptionProperties = commandLine.getOptionProperties( CLIManager.SET_SYSTEM_PROPERTY );
+
+ for ( String defStr : lineOptionProperties.stringPropertyNames( ) )
{
- for ( String defStr : defStrs )
- {
- setCliProperty( defStr, userProperties );
- }
+ String optValue = lineOptionProperties.getProperty( defStr );
+ userProperties.setProperty( defStr, optValue );
+
+ // ----------------------------------------------------------------------
+ // I'm leaving the setting of system properties here as not to break
+ // the SystemPropertyProfileActivator. This won't harm embedding. jvz.
+ // ----------------------------------------------------------------------
+ System.setProperty( defStr, optValue );
}
}
@@ -1677,37 +1681,6 @@ public class MavenCli
systemProperties.setProperty( "maven.build.version", mavenBuildVersion );
}
- private static void setCliProperty( String property, Properties properties )
- {
- String name;
-
- String value;
-
- int i = property.indexOf( '=' );
-
- if ( i <= 0 )
- {
- name = property.trim();
-
- value = "true";
- }
- else
- {
- name = property.substring( 0, i ).trim();
-
- value = property.substring( i + 1 );
- }
-
- properties.setProperty( name, value );
-
- // ----------------------------------------------------------------------
- // I'm leaving the setting of system properties here as not to break
- // the SystemPropertyProfileActivator. This won't harm embedding. jvz.
- // ----------------------------------------------------------------------
-
- System.setProperty( name, value );
- }
-
static class ExitException
extends Exception
{