[MSHARED-572] Drop Maven 2 Support
o Introduced CheckSumPolicy, ReactorFailureBehavior enumerations
instead of strings.
getGlobalChecksumPolicy() / setGlobalChecksumPolicy() using enum
setReactorFailureBehavior() / getReactorFailureBehavior() instead
of setFailureBehavior() / getFailureBehavior() and using enum as well.
o Removed activatedReactor, activatedReactorIncludes, activatedReactorExcludes
o Added builder id (--builder id) setBuilder() / getBuilder()
o Removed isInteractive()/setInteractive() and replaced with isBatchMode() / setBatchMode()
o Added getGlobalToolchainsFile() / setGlobalToolchainsFile()
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1752078 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
index c0cabbf..782a269 100644
--- a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
+++ b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
@@ -42,7 +42,7 @@
private InvocationOutputHandler errorHandler;
- private String failureBehavior = REACTOR_FAIL_FAST;
+ private ReactorFailureBehavior failureBehavior = ReactorFailureBehavior.FailFast;
private List<String> goals;
@@ -71,10 +71,12 @@
private File userSettings;
private File globalSettings;
-
+
private File toolchains;
- private String globalChecksumPolicy;
+ private File globalToolchains;
+
+ private CheckSumPolicy globalChecksumPolicy;
private String pomFilename;
@@ -87,11 +89,7 @@
private Map<String, String> shellEnvironments;
private String mavenOpts;
-
- private boolean activatedReactor;
- private String[] activatedReactorIncludes, activatedReactorExcludes;
-
private List<String> projects;
private boolean alsoMake;
@@ -104,13 +102,7 @@
private String threads;
- public InvocationRequest activateReactor( String[] includes, String[] excludes )
- {
- activatedReactor = true;
- activatedReactorIncludes = includes;
- activatedReactorExcludes = excludes;
- return this;
- }
+ private String builderId;
public File getBaseDirectory()
{
@@ -127,7 +119,7 @@
return errorHandler == null ? defaultHandler : errorHandler;
}
- public String getFailureBehavior()
+ public ReactorFailureBehavior getReactorFailureBehavior()
{
return failureBehavior;
}
@@ -167,7 +159,7 @@
return debug;
}
- public boolean isInteractive()
+ public boolean isBatchMode()
{
return interactive;
}
@@ -216,7 +208,7 @@
return this;
}
- public InvocationRequest setFailureBehavior( String failureBehavior )
+ public InvocationRequest setReactorFailureBehavior( ReactorFailureBehavior failureBehavior )
{
this.failureBehavior = failureBehavior;
return this;
@@ -234,7 +226,7 @@
return this;
}
- public InvocationRequest setInteractive( boolean interactive )
+ public InvocationRequest setBatchMode( boolean interactive )
{
this.interactive = interactive;
return this;
@@ -301,83 +293,146 @@
return javaHome;
}
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setJavaHome( File javaHome )
{
this.javaHome = javaHome;
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public File getUserSettingsFile()
{
return userSettings;
}
-
+
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setUserSettingsFile( File userSettings )
{
this.userSettings = userSettings;
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public File getGlobalSettingsFile()
{
return globalSettings;
}
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setGlobalSettingsFile( File globalSettings )
{
this.globalSettings = globalSettings;
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public File getToolchainsFile()
{
return toolchains;
}
-
+
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setToolchainsFile( File toolchains )
{
this.toolchains = toolchains;
return this;
}
-
- public String getGlobalChecksumPolicy()
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getGlobalToolchainsFile()
+ {
+ return globalToolchains;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InvocationRequest setGlobalToolchainsFile( File toolchains )
+ {
+ this.globalToolchains = toolchains;
+ return this;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public CheckSumPolicy getGlobalChecksumPolicy()
{
return globalChecksumPolicy;
}
- public InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
+ /**
+ * {@inheritDoc}
+ */
+ public InvocationRequest setGlobalChecksumPolicy( CheckSumPolicy globalChecksumPolicy )
{
this.globalChecksumPolicy = globalChecksumPolicy;
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public String getPomFileName()
{
return pomFilename;
}
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setPomFileName( String pomFilename )
{
this.pomFilename = pomFilename;
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public List<String> getProfiles()
{
return profiles;
}
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setProfiles( List<String> profiles )
{
this.profiles = profiles;
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public boolean isNonPluginUpdates()
{
return nonPluginUpdates;
}
+ /**
+ * {@inheritDoc}
+ */
public InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates )
{
this.nonPluginUpdates = nonPluginUpdates;
@@ -409,21 +464,6 @@
this.mavenOpts = mavenOpts;
return this;
}
-
- public boolean isActivatedReactor()
- {
- return activatedReactor;
- }
-
- public String[] getActivatedReactorIncludes()
- {
- return activatedReactorIncludes;
- }
-
- public String[] getActivatedReactorExcludes()
- {
- return activatedReactorExcludes;
- }
/**
* @see org.apache.maven.shared.invoker.InvocationRequest#isShowVersion()
@@ -441,7 +481,7 @@
this.showVersion = showVersion;
return this;
}
-
+
/**
* {@inheritDoc}
*/
@@ -449,7 +489,7 @@
{
return threads;
}
-
+
/**
* {@inheritDoc}
*/
@@ -526,5 +566,22 @@
this.resumeFrom = resumeFrom;
return this;
}
-
+
+ /**
+ * {@inheritDoc}
+ */
+ public InvocationRequest setBuilder( String id )
+ {
+ this.builderId = id;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBuilder()
+ {
+ return this.builderId;
+ }
+
}
diff --git a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java
index 453f52e..154b55b 100644
--- a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java
+++ b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java
@@ -81,13 +81,12 @@
{
cliBuilder.setMavenHome( getMavenHome() );
}
-
+
File mavenExecutable = getMavenExecutable();
if ( mavenExecutable != null )
{
cliBuilder.setMavenExecutable( mavenExecutable );
}
-
File workingDirectory = getWorkingDirectory();
if ( workingDirectory != null )
@@ -134,22 +133,8 @@
{
getLogger().debug( "Executing: " + cli );
}
- if ( request.isInteractive() )
- {
- if ( inputStream == null )
- {
- getLogger().warn(
- "Maven will be executed in interactive mode"
- + ", but no input stream has been configured for this MavenInvoker instance." );
- result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler );
- }
- else
- {
- result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler );
- }
- }
- else
+ if ( request.isBatchMode() )
{
if ( inputStream != null )
{
@@ -158,6 +143,20 @@
result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler );
}
+ else
+ {
+ if ( inputStream == null )
+ {
+ getLogger().warn( "Maven will be executed in interactive mode"
+ + ", but no input stream has been configured for this MavenInvoker instance." );
+
+ result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler );
+ }
+ else
+ {
+ result = CommandLineUtils.executeCommandLine( cli, inputStream, outputHandler, errorHandler );
+ }
+ }
return result;
}
diff --git a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java
index dea7d2f..ae88d26 100644
--- a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java
+++ b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java
@@ -33,21 +33,20 @@
public interface InvocationRequest
{
- // TODO: handle forced-reactor executions using -r/includes/excludes
-
/**
- * Gets the interaction mode of the Maven invocation. By default, Maven is executed in batch mode.
+ * By default, Maven is executed in batch mode. This mean no interaction with the Maven process can be done.
*
- * @return <code>true</code> if Maven should be executed in interactive mode, <code>false</code> if the batch
- * mode is used.
+ * @return <code>true</code> if Maven should be executed in batch mode, <code>false</code> if Maven is executed in
+ * interactive mode.
+ * @since 3.0.0
*/
- boolean isInteractive();
+ boolean isBatchMode();
/**
* Gets the network mode of the Maven invocation. By default, Maven is executed in online mode.
*
- * @return <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online mode
- * is used.
+ * @return <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online mode is
+ * used.
*/
boolean isOffline();
@@ -67,28 +66,8 @@
boolean isRecursive();
/**
- * Gets whether Maven should search subdirectories to build a dynamic reactor
- * @return <code>true</code> if we should search subdirectories, <code>false</code> otherwise
- */
- boolean isActivatedReactor();
-
- /**
- * Gets the list of subdirectory patterns to search
- * @return list of subdirectory patterns to search, or <code>null</code> in which case defaults should be used
- */
- String[] getActivatedReactorIncludes();
-
- /**
- * Gets the list of subdirectory patterns to exclude from search
- *
- * @return list of subdirectory patterns to exclude search, or <code>null</code> in which case nothing should be
- * excluded
- */
- String[] getActivatedReactorExcludes();
-
- /**
- * A list of specified reactor projects to build instead of all projects.
- * A project can be specified by [groupId]:artifactId or by its relative path.
+ * A list of specified reactor projects to build instead of all projects. A project can be specified by
+ * [groupId]:artifactId or by its relative path.
*
* @return the list of projects to add to reactor build, otherwise {@code null}
* @since 2.1
@@ -122,8 +101,8 @@
/**
* Gets the debug mode of the Maven invocation. By default, Maven is executed in normal mode.
*
- * @return <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode
- * should be used.
+ * @return <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode should
+ * be used.
*/
boolean isDebug();
@@ -151,20 +130,22 @@
boolean isNonPluginUpdates();
/**
- * Gets the failure mode of the Maven invocation. By default, the mode {@link #REACTOR_FAIL_FAST} is used.
+ * Gets the failure mode of the Maven invocation. By default, the mode {@link ReactorFailureBehavior#FailFast} is
+ * used.
*
- * @return The failure mode, one of {@link #REACTOR_FAIL_FAST}, {@link #REACTOR_FAIL_AT_END} and
- * {@link #REACTOR_FAIL_NEVER}.
+ * @return The failure mode, one of {@link ReactorFailureBehavior#FailFast},
+ * {@link ReactorFailureBehavior#FailAtEnd} and {@link ReactorFailureBehavior#FailNever}.
+ * @since 3.0.0
*/
- String getFailureBehavior();
+ ReactorFailureBehavior getReactorFailureBehavior();
/**
* Gets the path to the base directory of the local repository to use for the Maven invocation.
*
* @param defaultDirectory The default location to use if no location is configured for this request, may be
* <code>null</code>.
- * @return The path to the base directory of the local repository or <code>null</code> to use the location from
- * the <code>settings.xml</code>.
+ * @return The path to the base directory of the local repository or <code>null</code> to use the location from the
+ * <code>settings.xml</code>.
*/
File getLocalRepositoryDirectory( File defaultDirectory );
@@ -228,8 +209,8 @@
/**
* Gets the path to the base directory of the Java installation used to run Maven.
*
- * @return The path to the base directory of the Java installation used to run Maven or <code>null</code> to use
- * the default Java home.
+ * @return The path to the base directory of the Java installation used to run Maven or <code>null</code> to use the
+ * default Java home.
*/
File getJavaHome();
@@ -263,7 +244,7 @@
* @since 2.1
*/
File getGlobalSettingsFile();
-
+
/**
* Gets the path to the custom toolchains file
*
@@ -274,11 +255,21 @@
File getToolchainsFile();
/**
+ * Alternate path for the global toolchains file <b>Note. This is available starting with Maven 3.3.1</b>
+ *
+ * @return The path to the custom global toolchains file or <code>null</code> to load the global toolchains from the
+ * default location.
+ * @since 3.0.0
+ */
+ File getGlobalToolchainsFile();
+
+ /**
* Gets the checksum mode of the Maven invocation.
*
- * @return The checksum mode, one of {@link #CHECKSUM_POLICY_WARN} and {@link #CHECKSUM_POLICY_FAIL}.
+ * @return The checksum mode, one of {@link CheckSumPolicy#Warn} and {@link CheckSumPolicy#Fail}.
+ * @since 3.0.0
*/
- String getGlobalChecksumPolicy();
+ CheckSumPolicy getGlobalChecksumPolicy();
/**
* Gets the profiles for the Maven invocation.
@@ -300,10 +291,11 @@
* @return The value of the <code>MAVEN_OPTS</code> environment variable or <code>null</code> if not set.
*/
String getMavenOpts();
-
+
/**
- * The show version behaviour (-V option)
- * @return The show version behaviour
+ * The show version behavior (-V option)
+ *
+ * @return The show version behavior
* @since 2.0.11
*/
boolean isShowVersion();
@@ -321,71 +313,119 @@
// ----------------------------------------------------------------------
/**
- * The failure mode "fail-fast" where the build is stopped by the first failure.
+ * The reactor failure behavior which to be used during Maven invocation.
*/
- String REACTOR_FAIL_FAST = "fail-fast";
+ enum ReactorFailureBehavior
+ {
+ /**
+ * Stop at first failure in reactor builds
+ */
+ FailFast( "ff", "fail-fast" ),
+ /**
+ * Only fail the build afterwards. allow all non-impacted builds to continue.
+ */
+ FailAtEnd( "fae", "fail-at-end" ),
+ /**
+ * <b>NEVER</b> fail the build, regardless of project result
+ */
+ FailNever( "fn", "fail-never" );
- /**
- * The failure mode "fail-at-end" where the build is only failed at its very end if necessary.
- */
- String REACTOR_FAIL_AT_END = "fail-at-end";
+ private String shortOption;
- /**
- * The failure mode "fail-never" in which Maven will always exit with code 0 regardless of build failures.
- */
- String REACTOR_FAIL_NEVER = "fail-never";
+ private String longOption;
+
+ private ReactorFailureBehavior( String shortOption, String longOption )
+ {
+ this.shortOption = shortOption;
+ this.longOption = longOption;
+ }
+
+ public String getShortOption()
+ {
+ return this.shortOption;
+ }
+
+ public String getLongOption()
+ {
+ return this.longOption;
+ }
+
+ /**
+ * Returns the enumeration type which is related to the given long option.
+ *
+ * @param longOption The type which is searched for.
+ * @return The appropriate {@link ReactorFailureBehavior}
+ * @throws IllegalArgumentException in case of an long option which does not exists.
+ */
+ public static ReactorFailureBehavior valueOfByLongOption( String longOption )
+ {
+ for ( ReactorFailureBehavior item : ReactorFailureBehavior.values() )
+ {
+ if ( item.getLongOption().equals( longOption ) )
+ {
+ return item;
+ }
+ }
+ throw new IllegalArgumentException( "The string '" + longOption
+ + "' can not be converted to enumeration." );
+ }
+ };
// ----------------------------------------------------------------------
// Artifact repository policies
// ----------------------------------------------------------------------
/**
- * The strict checksum policy which fails the build if a corrupt artifact is detected.
+ * The kind of checksum policy which should be used during Maven invocation.
*/
- String CHECKSUM_POLICY_FAIL = "fail";
+ enum CheckSumPolicy
+ {
- /**
- * The lax checksum policy which only outputs a warning if a corrupt artifact is detected.
- */
- String CHECKSUM_POLICY_WARN = "warn";
+ /**
+ * Strict checksum checking equivalent of {@code --strict-checksums}
+ */
+ Fail,
+ /**
+ * Warn checksum failures equivalent {@code --lax-checksums}.
+ */
+ Warn;
+
+ }
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
/**
- * Sets the interaction mode of the Maven invocation.
- * <em>Inverse</em> equivalent of {@code -B} and {@code --batch-mode}
+ * Sets the interaction mode of the Maven invocation. Equivalent of {@code -B} and {@code --batch-mode}
*
- * @param interactive <code>true</code> if Maven should be executed in interactive mode, <code>false</code> if
- * the batch mode is used.
+ * @param batchMode <code>true</code> if Maven should be executed in non-interactive mode, <code>false</code> if the
+ * interactive modes is used.
* @return This invocation request.
+ * @since 3.0.0
*/
- InvocationRequest setInteractive( boolean interactive );
+ InvocationRequest setBatchMode( boolean batchMode );
/**
- * Sets the network mode of the Maven invocation.
- * Equivalent of {@code -o} and {@code --offline}
+ * Sets the network mode of the Maven invocation. Equivalent of {@code -o} and {@code --offline}
*
- * @param offline <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the
- * online mode is used.
+ * @param offline <code>true</code> if Maven should be executed in offline mode, <code>false</code> if the online
+ * mode is used.
* @return This invocation request.
*/
InvocationRequest setOffline( boolean offline );
/**
- * Sets the debug mode of the Maven invocation.
- * Equivalent of {@code -X} and {@code --debug}
+ * Sets the debug mode of the Maven invocation. Equivalent of {@code -X} and {@code --debug}
*
- * @param debug <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal
- * mode should be used.
+ * @param debug <code>true</code> if Maven should be executed in debug mode, <code>false</code> if the normal mode
+ * should be used.
* @return This invocation request.
*/
InvocationRequest setDebug( boolean debug );
/**
- * Sets the exception output mode of the Maven invocation.
- * Equivalent of {@code -e} and {@code --errors}
+ * Sets the exception output mode of the Maven invocation. Equivalent of {@code -e} and {@code --errors}
*
* @param showErrors <code>true</code> if Maven should print stack traces, <code>false</code> otherwise.
* @return This invocation request.
@@ -393,8 +433,8 @@
InvocationRequest setShowErrors( boolean showErrors );
/**
- * Specifies whether Maven should enforce an update check for plugins and snapshots.
- * Equivalent of {@code -U} and {@code --update-snapshots}
+ * Specifies whether Maven should enforce an update check for plugins and snapshots. Equivalent of {@code -U} and
+ * {@code --update-snapshots}
*
* @param updateSnapshots <code>true</code> if plugins and snapshots should be updated, <code>false</code>
* otherwise.
@@ -406,19 +446,12 @@
* Sets the failure mode of the Maven invocation. Equivalent of {@code -ff} and {@code --fail-fast}, {@code -fae}
* and {@code --fail-at-end}, {@code -fn} and {@code --fail-never}
*
- * @param failureBehavior The failure mode, must be one of {@link #REACTOR_FAIL_FAST}, {@link #REACTOR_FAIL_AT_END}
- * and {@link #REACTOR_FAIL_NEVER}.
+ * @param failureBehavior The failure mode, must be one of {@link ReactorFailureBehavior#FailFast},
+ * {@link ReactorFailureBehavior#FailAtEnd} and {@link ReactorFailureBehavior#FailNever}.
* @return This invocation request.
+ * @since 3.0.0
*/
- InvocationRequest setFailureBehavior( String failureBehavior );
-
- /**
- * Dynamically constructs a reactor using the subdirectories of the current directory
- * @param includes a list of filename patterns to include, or null, in which case the default is */pom.xml
- * @param excludes a list of filename patterns to exclude, or null, in which case nothing is excluded
- * @return This invocation request
- */
- InvocationRequest activateReactor( String[] includes, String[] excludes );
+ InvocationRequest setReactorFailureBehavior( ReactorFailureBehavior failureBehavior );
/**
* Sets the path to the base directory of the local repository to use for the Maven invocation.
@@ -509,8 +542,7 @@
InvocationRequest setGoals( List<String> goals );
/**
- * Sets the profiles for the Maven invocation.
- * Equivalent of {@code -P} and {@code --active-profiles}
+ * Sets the profiles for the Maven invocation. Equivalent of {@code -P} and {@code --active-profiles}
*
* @param profiles The profiles for the Maven invocation, may be <code>null</code> to use the default profiles.
* @return This invocation request.
@@ -527,18 +559,17 @@
InvocationRequest setShellEnvironmentInherited( boolean shellEnvironmentInherited );
/**
- * Sets the path to the user settings for the Maven invocation.
- * Equivalent of {@code -s} and {@code --settings}
- *
- * @param userSettings The path to the user settings for the Maven invocation, may be <code>null</code> to load
- * the user settings from the default location.
+ * Sets the path to the user settings for the Maven invocation. Equivalent of {@code -s} and {@code --settings}
+ *
+ * @param userSettings The path to the user settings for the Maven invocation, may be <code>null</code> to load the
+ * user settings from the default location.
* @return This invocation request.
*/
InvocationRequest setUserSettingsFile( File userSettings );
/**
- * Sets the path to the global settings for the Maven invocation.
- * Equivalent of {@code -gs} and {@code --global-settings}
+ * Sets the path to the global settings for the Maven invocation. Equivalent of {@code -gs} and
+ * {@code --global-settings}
*
* @param globalSettings The path to the global settings for the Maven invocation, may be <code>null</code> to load
* the global settings from the default location.
@@ -548,42 +579,49 @@
InvocationRequest setGlobalSettingsFile( File globalSettings );
/**
- * Sets the alternate path for the user toolchains file
- * Equivalent of {@code -t} or {@code --toolchains}
- * <p>
- * <strong>note: </strong>available since Maven3
- * </p>
+ * Sets the alternate path for the user toolchains file Equivalent of {@code -t} or {@code --toolchains}
*
* @param toolchains the alternate path for the user toolchains file
* @return This invocation request
* @since 2.1
*/
InvocationRequest setToolchainsFile( File toolchains );
+
/**
- * Sets the checksum mode of the Maven invocation.
- * Equivalent of {@code -c} or {@code --lax-checksums}, {@code -C} or {@code --strict-checksums}
+ * Sets the alternate path for the global toolchains file Equivalent of {@code -gt} or {@code --global-toolchains}
*
- * @param globalChecksumPolicy The checksum mode, must be one of {@link #CHECKSUM_POLICY_WARN} and
- * {@link #CHECKSUM_POLICY_FAIL}.
- * @return This invocation request.
+ * @param toolchains the alternate path for the global toolchains file
+ * @return This invocation request
+ * @since 3.0.0
*/
- InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy );
+ InvocationRequest setGlobalToolchainsFile( File toolchains );
+
+ /**
+ * Sets the checksum mode of the Maven invocation. Equivalent of {@code -c} or {@code --lax-checksums}, {@code -C}
+ * or {@code --strict-checksums}
+ *
+ * @param globalChecksumPolicy The checksum mode, must be one of {@link CheckSumPolicy#Warn} and
+ * {@link CheckSumPolicy#Fail}.
+ * @return This invocation request.
+ * @since 3.0.0
+ */
+ InvocationRequest setGlobalChecksumPolicy( CheckSumPolicy globalChecksumPolicy );
/**
* Specifies whether Maven should check for plugin updates.
* <p>
- * Equivalent of {@code -npu} or {@code --no-plugin-updates}<br/>
+ * Equivalent of {@code -npu} or {@code --no-plugin-updates}<br/>
* <strong>note: </strong>Ineffective with Maven3, only kept for backward compatibility
* </p>
- * @param nonPluginUpdates <code>true</code> if plugin updates should be suppressed, <code>false</code>
- * otherwise.
+ *
+ * @param nonPluginUpdates <code>true</code> if plugin updates should be suppressed, <code>false</code> otherwise.
* @return This invocation request.
*/
InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates );
/**
- * Sets the recursion behavior of a reactor invocation.
- * <em>Inverse</em> equivalent of {@code -N} and {@code --non-recursive}
+ * Sets the recursion behavior of a reactor invocation. <em>Inverse</em> equivalent of {@code -N} and
+ * {@code --non-recursive}
*
* @param recursive <code>true</code> if sub modules should be build, <code>false</code> otherwise.
* @return This invocation request.
@@ -602,25 +640,23 @@
/**
* Sets the value of the <code>MAVEN_OPTS</code> environment variable.
*
- * @param mavenOpts The value of the <code>MAVEN_OPTS</code> environment variable, may be <code>null</code> to
- * use the default options.
+ * @param mavenOpts The value of the <code>MAVEN_OPTS</code> environment variable, may be <code>null</code> to use
+ * the default options.
* @return This invocation request.
*/
InvocationRequest setMavenOpts( String mavenOpts );
-
+
/**
- * enable displaying version without stopping the build
- * Equivalent of {@code -V} or {@code --show-version}
+ * enable displaying version without stopping the build Equivalent of {@code -V} or {@code --show-version}
*
- * @param showVersion enable displaying version
+ * @param showVersion enable displaying version
* @return This invocation request.
* @since 2.0.11
*/
InvocationRequest setShowVersion( boolean showVersion );
/**
- * Thread count, for instance 2.0C where C is core multiplied
- * Equivalent of {@code -T} or {@code --threads}
+ * Thread count, for instance 2.0C where C is core multiplied Equivalent of {@code -T} or {@code --threads}
* <p>
* <strong>note: </strong>available since Maven3
* </p>
@@ -632,20 +668,18 @@
InvocationRequest setThreads( String threads );
/**
- * Sets the reactor project list.
- * Equivalent of {@code -P} or {@code --projects}
+ * Sets the reactor project list. Equivalent of {@code -pl} or {@code --projects}
*
- * @param projects the reactor project list
+ * @param projects the reactor project list
* @return This invocation request.
* @since 2.1
*/
InvocationRequest setProjects( List<String> projects );
/**
- * Enable the 'also make' mode.
- * Equivalent of {@code -am} or {@code --also-make}
+ * Enable the 'also make' mode. Equivalent of {@code -am} or {@code --also-make}
*
- * @param alsoMake enable 'also make' mode
+ * @param alsoMake enable 'also make' mode
* @return This invocation request.
* @since 2.1
*/
@@ -661,13 +695,28 @@
InvocationRequest setAlsoMakeDependents( boolean alsoMakeDependents );
/**
- * Resume reactor from specified project.
- * Equivalent of {@code -rf} or {@code --resume-from}
+ * Resume reactor from specified project. Equivalent of {@code -rf} or {@code --resume-from}
*
* @param resumeFrom set the project to resume from
* @return This invocation request
* @since 2.1
*/
InvocationRequest setResumeFrom( String resumeFrom );
-
+
+ /**
+ * The id of the build strategy to use. equivalent of {@code --builder id}.
+ *
+ * @param id The builder id.
+ * @return {@link InvocationRequest} FIXME: How to identify if this is a valid command line option?
+ * @since 3.2.1
+ */
+ InvocationRequest setBuilder( String id );
+
+ /**
+ * Get the current set builder strategy id equivalent of {@code --builder id}.
+ *
+ * @return The current set build id.
+ */
+ String getBuilder();
+
}
diff --git a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
index e27e45a..49723c1 100644
--- a/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
+++ b/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
@@ -27,6 +27,8 @@
import java.util.Map.Entry;
import java.util.Properties;
+import org.apache.maven.shared.invoker.InvocationRequest.CheckSumPolicy;
+import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -96,7 +98,7 @@
setSettingsLocation( request, cli );
setToolchainsLocation( request, cli );
-
+
setProperties( request, cli );
setProfiles( request, cli );
@@ -104,7 +106,7 @@
setGoals( request, cli );
setThreads( request, cli );
-
+
return cli;
}
@@ -149,7 +151,7 @@
cli.createArg().setValue( "-s" );
cli.createArg().setValue( userSettingsFile.getPath() );
}
-
+
File globalSettingsFile = request.getGlobalSettingsFile();
if ( globalSettingsFile != null )
@@ -170,7 +172,7 @@
}
}
-
+
protected void setToolchainsLocation( InvocationRequest request, Commandline cli )
{
File toolchainsFile = request.getToolchainsFile();
@@ -202,7 +204,8 @@
{
cli.addSystemEnvironment();
cli.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );
- // MSHARED-261: Ensure M2_HOME is not inherited, but gets a proper value
+ // MSHARED-261: Ensure M2_HOME is not inherited, but gets a
+ // proper value
cli.addEnvironment( "M2_HOME", getMavenHome().getAbsolutePath() );
}
catch ( IOException e )
@@ -415,35 +418,19 @@
protected void setReactorBehavior( InvocationRequest request, Commandline cli )
{
// NOTE: The default is "fail-fast"
- String failureBehavior = request.getFailureBehavior();
+ ReactorFailureBehavior failureBehavior = request.getReactorFailureBehavior();
- if ( StringUtils.isNotEmpty( failureBehavior ) )
+ if ( failureBehavior != null )
{
- if ( InvocationRequest.REACTOR_FAIL_AT_END.equals( failureBehavior ) )
+ if ( ReactorFailureBehavior.FailAtEnd.equals( failureBehavior ) )
{
- cli.createArg().setValue( "-fae" );
+ cli.createArg().setValue( "-" + ReactorFailureBehavior.FailAtEnd.getShortOption() );
}
- else if ( InvocationRequest.REACTOR_FAIL_NEVER.equals( failureBehavior ) )
+ else if ( ReactorFailureBehavior.FailNever.equals( failureBehavior ) )
{
- cli.createArg().setValue( "-fn" );
+ cli.createArg().setValue( "-" + ReactorFailureBehavior.FailNever.getShortOption() );
}
- }
- if ( request.isActivatedReactor() )
- {
- cli.createArg().setValue( "-r" );
- String[] includes = request.getActivatedReactorIncludes();
- String[] excludes = request.getActivatedReactorExcludes();
- if ( includes != null )
- {
- cli.createArg().setValue( "-D" );
- cli.createArg().setValue( "maven.reactor.includes=" + StringUtils.join( includes, "," ) );
- }
- if ( excludes != null )
- {
- cli.createArg().setValue( "-D" );
- cli.createArg().setValue( "maven.reactor.excludes=" + StringUtils.join( excludes, "," ) );
- }
}
if ( StringUtils.isNotEmpty( request.getResumeFrom() ) )
@@ -472,7 +459,7 @@
protected void setFlags( InvocationRequest request, Commandline cli )
{
- if ( !request.isInteractive() )
+ if ( request.isBatchMode() )
{
cli.createArg().setValue( "-B" );
}
@@ -496,18 +483,18 @@
{
cli.createArg().setValue( "-X" );
}
- // this is superceded by -X, if it exists.
+ // this is superseded by -X, if it exists.
else if ( request.isShowErrors() )
{
cli.createArg().setValue( "-e" );
}
- String checksumPolicy = request.getGlobalChecksumPolicy();
- if ( InvocationRequest.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) )
+ CheckSumPolicy checksumPolicy = request.getGlobalChecksumPolicy();
+ if ( CheckSumPolicy.Fail.equals( checksumPolicy ) )
{
cli.createArg().setValue( "-C" );
}
- else if ( InvocationRequest.CHECKSUM_POLICY_WARN.equals( checksumPolicy ) )
+ else if ( CheckSumPolicy.Warn.equals( checksumPolicy ) )
{
cli.createArg().setValue( "-c" );
}
@@ -515,11 +502,16 @@
{
cli.createArg().setValue( "-npu" );
}
-
+
if ( request.isShowVersion() )
{
cli.createArg().setValue( "-V" );
}
+
+ if ( request.getBuilder() != null )
+ {
+ cli.createArg().setValue( request.getBuilder() );
+ }
}
protected void setThreads( InvocationRequest request, Commandline cli )
@@ -530,7 +522,7 @@
cli.createArg().setValue( "-T" );
cli.createArg().setValue( threads );
}
-
+
}
protected File findMavenExecutable()
@@ -589,9 +581,9 @@
{
executable = "mvn";
}
-
+
mavenExecutable = new File( mavenHome, "/bin/" + executable );
-
+
try
{
File canonicalMvn = mavenExecutable.getCanonicalFile();
@@ -682,7 +674,7 @@
}
/**
- * {@code mavenExecutable} can either be relative to ${maven.home}/bin/ or absolute
+ * {@code mavenExecutable} can either be relative to ${maven.home}/bin/ or absolute
*
* @param mavenExecutable the executable
*/
diff --git a/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java b/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
index 7d67d4f..ee3a000 100644
--- a/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
+++ b/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
@@ -386,7 +386,7 @@
TestCommandLineBuilder tcb = new TestCommandLineBuilder();
Commandline cli = new Commandline();
- tcb.setFlags( newRequest().setInteractive( false ), cli );
+ tcb.setFlags( newRequest().setBatchMode( true ), cli );
assertArgumentsPresent( cli, Collections.singleton( "-B" ) );
}
@@ -458,41 +458,6 @@
}
@Test
- public void testActivateReactor()
- {
- logTestStart();
-
- TestCommandLineBuilder tcb = new TestCommandLineBuilder();
- Commandline cli = new Commandline();
-
- tcb.setReactorBehavior( newRequest().activateReactor( null, null ), cli );
-
- assertArgumentsPresent( cli, Collections.singleton( "-r" ) );
- }
-
- @Test
- public void testActivateReactorIncludesExcludes()
- {
- logTestStart();
-
- TestCommandLineBuilder tcb = new TestCommandLineBuilder();
- Commandline cli = new Commandline();
-
- String[] includes = new String[] { "foo", "bar" };
- String[] excludes = new String[] { "baz", "quz" };
-
- tcb.setReactorBehavior( newRequest().activateReactor( includes, excludes ), cli );
-
- Set<String> args = new HashSet<String>();
- args.add( "-r" );
- args.add( "-D" );
- args.add( "maven.reactor.includes=foo,bar" );
- args.add( "maven.reactor.excludes=baz,quz" );
-
- assertArgumentsPresent( cli, args );
- }
-
- @Test
public void testAlsoMake()
{
logTestStart();
@@ -583,7 +548,7 @@
TestCommandLineBuilder tcb = new TestCommandLineBuilder();
Commandline cli = new Commandline();
- tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CHECKSUM_POLICY_FAIL ), cli );
+ tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Fail ), cli );
assertArgumentsPresent( cli, Collections.singleton( "-C" ) );
}
@@ -596,7 +561,7 @@
TestCommandLineBuilder tcb = new TestCommandLineBuilder();
Commandline cli = new Commandline();
- tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CHECKSUM_POLICY_WARN ), cli );
+ tcb.setFlags( newRequest().setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Warn ), cli );
assertArgumentsPresent( cli, Collections.singleton( "-c" ) );
}
@@ -609,7 +574,8 @@
TestCommandLineBuilder tcb = new TestCommandLineBuilder();
Commandline cli = new Commandline();
- tcb.setReactorBehavior( newRequest().setFailureBehavior( InvocationRequest.REACTOR_FAIL_AT_END ), cli );
+ tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailAtEnd ),
+ cli );
assertArgumentsPresent( cli, Collections.singleton( "-fae" ) );
}
@@ -622,7 +588,8 @@
TestCommandLineBuilder tcb = new TestCommandLineBuilder();
Commandline cli = new Commandline();
- tcb.setReactorBehavior( newRequest().setFailureBehavior( InvocationRequest.REACTOR_FAIL_NEVER ), cli );
+ tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailNever ),
+ cli );
assertArgumentsPresent( cli, Collections.singleton( "-fn" ) );
}
@@ -635,7 +602,8 @@
TestCommandLineBuilder tcb = new TestCommandLineBuilder();
Commandline cli = new Commandline();
- tcb.setReactorBehavior( newRequest().setFailureBehavior( InvocationRequest.REACTOR_FAIL_FAST ), cli );
+ tcb.setReactorBehavior( newRequest().setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailFast ),
+ cli );
Set<String> banned = new HashSet<String>();
banned.add( "-fae" );
@@ -1312,7 +1280,7 @@
}
assertEquals( "Arguments: " + expected + " were not found or are in the wrong order: "
- + Arrays.asList( arguments ), expected.size(), expectedCounter );
+ + Arrays.asList( arguments ), expected.size(), expectedCounter );
}
private void assertArgumentsPresent( Commandline cli, Set<String> requiredArgs )