null
if the command line was successfully
* processed by the operating system.
*/
CommandLineException getExecutionException();
/**
* Gets the exit code from the Maven invocation. A non-zero value indicates a build failure. Note:
* This value is undefined if {@link #getExecutionException()} reports an exception.
*
* @return The exit code from the Maven invocation.
*/
int getExitCode();
}
././@LongLink 0000644 0000000 0000000 00000000151 12232232274 011636 L ustar root root maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/CommandLineConfigurationException.java maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/CommandLineConfigurationException.0000664 0001750 0001750 00000003452 11020276126 033122 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.
*/
/**
* Signals an error during the construction of the command line used to invoke Maven.
*
* @version $Id: CommandLineConfigurationException.java 662043 2008-05-31 16:27:02Z bentmann $
*/
public class CommandLineConfigurationException
extends Exception
{
private static final long serialVersionUID = 1L;
/**
* Creates a new exception using the specified detail message and cause.
*
* @param message The detail message for this exception, may be null
.
* @param cause The nested exception, may be null
.
*/
public CommandLineConfigurationException( String message, Throwable cause )
{
super( message, cause );
}
/**
* Creates a new exception using the specified detail message.
*
* @param message The detail message for this exception, may be null
.
*/
public CommandLineConfigurationException( String message )
{
super( message );
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/Invoker.java 0000664 0001750 0001750 00000014556 12034117565 026622 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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 java.io.File;
import java.io.InputStream;
/**
* Provides a facade to invoke Maven.
*
* @version $Id: Invoker.java 1395172 2012-10-06 21:15:33Z rfscholte $
*/
public interface Invoker
{
/**
* The role name used to register implementations of this interface within Plexus.
*/
String ROLE = Invoker.class.getName();
/**
* @deprecated Query this property by yourself, this has nothing to do with invoking Maven and as such does not
* belong into this API!
*/
String userHome = System.getProperty( "user.home" );
/**
* Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the
* invocation request will be derived from the state of this invoker instance. In case both the invoker instance and
* the invocation request provide a value for a particular option, the value from the invocation request dominates.
*
* @param request The invocation request to execute, must not be null
.
* @return The result of the Maven invocation, never null
.
* @throws MavenInvocationException
*/
InvocationResult execute( InvocationRequest request )
throws MavenInvocationException;
/**
* Gets the path to the base directory of the local repository to use for the Maven invocation.
*
* @return The path to the base directory of the local repository or null
to use the location from
* the settings.xml
.
*/
File getLocalRepositoryDirectory();
/**
* Gets the working directory for the Maven invocation.
*
* @return The working directory for the Maven invocation or null
if the working directory is derived
* from the base directory of the processed POM.
*/
File getWorkingDirectory();
/**
* Gets the logger used by this invoker to output diagnostic messages.
*
* @return The logger used by this invoker to output diagnostic messages, never null
.
*/
InvokerLogger getLogger();
/**
* Gets the path to the base directory of the Maven installation used to invoke Maven.
*
* @return The path to the base directory of the Maven installation or null
if using the default
* Maven installation.
*/
File getMavenHome();
/**
* Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left
* unspecified to use the default Maven installation which will be discovered by evaluating the system property
* maven.home
and the environment variable M2_HOME
.
*
* @param mavenHome The path to the base directory of the Maven installation, may be null
to use the
* default Maven installation.
* @return This invoker instance.
*/
Invoker setMavenHome( File mavenHome );
/**
* Get the customized File of the Maven executable.
*
* @return the custom Maven executable, otherwise {@code null}
*/
File getMavenExecutable();
/**
* {@code mavenExecutable} can either be a file relative to ${maven.home}/bin/ or an absolute file.
*
* @param mavenExecutable the executable
* @return This invoker instance
*/
Invoker setMavenExecutable( File mavenExecutable );
/**
* Sets the path to the base directory of the local repository to use for the Maven invocation.
*
* @param localRepositoryDirectory The path to the base directory of the local repository or null
to
* use the location from the settings.xml
.
* @return This invoker instance.
*/
Invoker setLocalRepositoryDirectory( File localRepositoryDirectory );
/**
* Sets the logger used by this invoker to output diagnostic messages.
*
* @param logger The logger used by this invoker to output diagnostic messages, may be null
to use a
* default logger.
* @return This invoker instance.
*/
Invoker setLogger( InvokerLogger logger );
/**
* Sets the working directory for the Maven invocation.
*
* @param workingDirectory The working directory for the Maven invocation, may be null
to derive the
* working directory from the base directory of the processed POM.
* @return This invoker instance.
*/
Invoker setWorkingDirectory( File workingDirectory );
/**
* Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when
* invoking Maven in interactive mode.
*
* @param inputStream The input stream used to provide input for the invoked Maven build, may be null
* if not required.
* @return This invoker instance.
*/
Invoker setInputStream( InputStream inputStream );
/**
* Sets the handler used to capture the standard output from the Maven build.
*
* @param outputHandler The output handler, may be null
if the output is not of interest.
* @return This invoker instance.
*/
Invoker setOutputHandler( InvocationOutputHandler outputHandler );
/**
* Sets the handler used to capture the error output from the Maven build.
*
* @param errorHandler The error handler, may be null
if the output is not of interest.
* @return This invoker instance.
*/
Invoker setErrorHandler( InvocationOutputHandler errorHandler );
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/InvocationOutputHandler.java 0000664 0001750 0001750 00000002211 12042043133 032002 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.codehaus.plexus.util.cli.StreamConsumer;
/**
* Receives the standard/error output from a Maven invocation.
*
* @version $Id: InvocationOutputHandler.java 1401842 2012-10-24 19:49:47Z rfscholte $
*/
public interface InvocationOutputHandler
extends StreamConsumer
{
// empty by design
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationResult.java 0000664 0001750 0001750 00000004456 12042043133 032004 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.codehaus.plexus.util.cli.CommandLineException;
/**
* Describes the result of a Maven invocation.
*
* @version $Id: DefaultInvocationResult.java 1401842 2012-10-24 19:49:47Z rfscholte $
*/
public final class DefaultInvocationResult
implements InvocationResult
{
/**
* The exception that prevented to execute the command line, will be null
if Maven could be
* successfully started.
*/
private CommandLineException executionException;
/**
* The exit code reported by the Maven invocation.
*/
private int exitCode = Integer.MIN_VALUE;
/**
* Creates a new invocation result
*/
DefaultInvocationResult()
{
// hide constructor
}
public int getExitCode()
{
return exitCode;
}
public CommandLineException getExecutionException()
{
return executionException;
}
/**
* Sets the exit code reported by the Maven invocation.
*
* @param exitCode The exit code reported by the Maven invocation.
*/
void setExitCode( int exitCode )
{
this.exitCode = exitCode;
}
/**
* Sets the exception that prevented to execute the command line.
*
* @param executionException The exception that prevented to execute the command line, may be null
.
*/
void setExecutionException( CommandLineException executionException )
{
this.executionException = executionException;
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/SystemOutHandler.java 0000664 0001750 0001750 00000002651 11020226576 030445 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.
*/
/**
* Offers an output handler that writes to {@link System#out}.
*
* @version $Id: SystemOutHandler.java 661996 2008-05-31 10:50:38Z bentmann $
*/
public class SystemOutHandler
extends PrintStreamHandler
{
/**
* Creates a new output handler.
*/
public SystemOutHandler()
{
this( false );
}
/**
* Creates a new output handler.
*
* @param alwaysFlush A flag whether the print stream should be flushed after each line.
*/
public SystemOutHandler( boolean alwaysFlush )
{
super( System.out, alwaysFlush );
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/PrintStreamHandler.java 0000664 0001750 0001750 00000004463 11045044160 030736 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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 java.io.PrintStream;
/**
* Offers an output handler that writes to a print stream like {@link System#out}.
*
* @version $Id: PrintStreamHandler.java 681956 2008-08-02 11:43:44Z dennisl $
* @since 2.0.9
*/
public class PrintStreamHandler
implements InvocationOutputHandler
{
/**
* The print stream to write to, never null
.
*/
private PrintStream out;
/**
* A flag whether the print stream should be flushed after each line.
*/
private boolean alwaysFlush;
/**
* Creates a new output handler that writes to {@link System#out}.
*/
public PrintStreamHandler()
{
this( System.out, false );
}
/**
* Creates a new output handler that writes to the specified print stream.
*
* @param out The print stream to write to, must not be null
.
* @param alwaysFlush A flag whether the print stream should be flushed after each line.
*/
public PrintStreamHandler( PrintStream out, boolean alwaysFlush )
{
if ( out == null )
{
throw new NullPointerException( "missing output stream" );
}
this.out = out;
this.alwaysFlush = alwaysFlush;
}
public void consumeLine( String line )
{
if ( line == null )
{
out.println();
}
else
{
out.println( line );
}
if ( alwaysFlush )
{
out.flush();
}
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/SystemOutLogger.java 0000664 0001750 0001750 00000002276 11020226576 030312 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.
*/
/**
* Offers a logger that writes to {@link System#out}.
*
* @version $Id: SystemOutLogger.java 661996 2008-05-31 10:50:38Z bentmann $
*/
public class SystemOutLogger
extends PrintStreamLogger
{
/**
* Creates a new logger with a threshold of {@link #INFO}.
*/
public SystemOutLogger()
{
super( System.out, INFO );
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/MavenInvocationException.java 0000664 0001750 0001750 00000003734 11020276126 032151 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.
*/
/**
* Signals an error during the construction of the command line used to invoke Maven, e.g. illegal invocation arguments.
* This should not be confused with a failure of the invoked Maven build itself which will be reported by means of a
* non-zero exit code.
*
* @see InvocationResult#getExitCode()
* @version $Id: MavenInvocationException.java 662043 2008-05-31 16:27:02Z bentmann $
*/
public class MavenInvocationException
extends Exception
{
private static final long serialVersionUID = 1L;
/**
* Creates a new exception using the specified detail message and cause.
*
* @param message The detail message for this exception, may be null
.
* @param cause The nested exception, may be null
.
*/
public MavenInvocationException( String message, Throwable cause )
{
super( message, cause );
}
/**
* Creates a new exception using the specified detail message.
*
* @param message The detail message for this exception, may be null
.
*/
public MavenInvocationException( String message )
{
super( message );
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java 0000664 0001750 0001750 00000015201 12042301555 030104 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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 java.io.File;
import java.io.InputStream;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
/**
* Class intended to be used by clients who wish to invoke a forked Maven process from their applications
*
* @author jdcasey
*/
@Component( role = Invoker.class, hint = "default" )
public class DefaultInvoker
implements Invoker
{
public static final String ROLE_HINT = "default";
private static final InvokerLogger DEFAULT_LOGGER = new SystemOutLogger();
private static final InvocationOutputHandler DEFAULT_OUTPUT_HANDLER = new SystemOutHandler();
private File localRepositoryDirectory;
private InvokerLogger logger = DEFAULT_LOGGER;
private File workingDirectory;
private File mavenHome;
private File mavenExecutable;
private InvocationOutputHandler outputHandler = DEFAULT_OUTPUT_HANDLER;
private InputStream inputStream;
private InvocationOutputHandler errorHandler = DEFAULT_OUTPUT_HANDLER;
public InvocationResult execute( InvocationRequest request )
throws MavenInvocationException
{
MavenCommandLineBuilder cliBuilder = new MavenCommandLineBuilder();
InvokerLogger logger = getLogger();
if ( logger != null )
{
cliBuilder.setLogger( getLogger() );
}
File localRepo = getLocalRepositoryDirectory();
if ( localRepo != null )
{
cliBuilder.setLocalRepositoryDirectory( getLocalRepositoryDirectory() );
}
File mavenHome = getMavenHome();
if ( mavenHome != null )
{
cliBuilder.setMavenHome( getMavenHome() );
}
File mavenExecutable = getMavenExecutable();
if ( mavenExecutable != null )
{
cliBuilder.setMavenExecutable( mavenExecutable );
}
File workingDirectory = getWorkingDirectory();
if ( workingDirectory != null )
{
cliBuilder.setWorkingDirectory( getWorkingDirectory() );
}
Commandline cli;
try
{
cli = cliBuilder.build( request );
}
catch ( CommandLineConfigurationException e )
{
throw new MavenInvocationException( "Error configuring command-line. Reason: " + e.getMessage(), e );
}
DefaultInvocationResult result = new DefaultInvocationResult();
try
{
int exitCode = executeCommandLine( cli, request );
result.setExitCode( exitCode );
}
catch ( CommandLineException e )
{
result.setExecutionException( e );
}
return result;
}
private int executeCommandLine( Commandline cli, InvocationRequest request )
throws CommandLineException
{
int result = Integer.MIN_VALUE;
InputStream inputStream = request.getInputStream( this.inputStream );
InvocationOutputHandler outputHandler = request.getOutputHandler( this.outputHandler );
InvocationOutputHandler errorHandler = request.getErrorHandler( this.errorHandler );
if ( getLogger().isDebugEnabled() )
{
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 ( inputStream != null )
{
getLogger().info( "Executing in batch mode. The configured input stream will be ignored." );
}
result = CommandLineUtils.executeCommandLine( cli, outputHandler, errorHandler );
}
return result;
}
public File getLocalRepositoryDirectory()
{
return localRepositoryDirectory;
}
public InvokerLogger getLogger()
{
return logger;
}
public Invoker setLocalRepositoryDirectory( File localRepositoryDirectory )
{
this.localRepositoryDirectory = localRepositoryDirectory;
return this;
}
public Invoker setLogger( InvokerLogger logger )
{
this.logger = ( logger != null ) ? logger : DEFAULT_LOGGER;
return this;
}
public File getWorkingDirectory()
{
return workingDirectory;
}
public Invoker setWorkingDirectory( File workingDirectory )
{
this.workingDirectory = workingDirectory;
return this;
}
public File getMavenHome()
{
return mavenHome;
}
public Invoker setMavenHome( File mavenHome )
{
this.mavenHome = mavenHome;
return this;
}
public File getMavenExecutable()
{
return mavenExecutable;
}
public Invoker setMavenExecutable( File mavenExecutable )
{
this.mavenExecutable = mavenExecutable;
return this;
}
public Invoker setErrorHandler( InvocationOutputHandler errorHandler )
{
this.errorHandler = errorHandler;
return this;
}
public Invoker setInputStream( InputStream inputStream )
{
this.inputStream = inputStream;
return this;
}
public Invoker setOutputHandler( InvocationOutputHandler outputHandler )
{
this.outputHandler = outputHandler;
return this;
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java 0000664 0001750 0001750 00000050620 12042043133 031645 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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 java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
/**
* @version $Id: MavenCommandLineBuilder.java 1401842 2012-10-24 19:49:47Z rfscholte $
*/
public class MavenCommandLineBuilder
{
private static final InvokerLogger DEFAULT_LOGGER = new SystemOutLogger();
private InvokerLogger logger = DEFAULT_LOGGER;
private File workingDirectory;
private File localRepositoryDirectory;
private File mavenHome;
private File mavenExecutable;
private Properties systemEnvVars;
public Commandline build( InvocationRequest request )
throws CommandLineConfigurationException
{
try
{
checkRequiredState();
}
catch ( IOException e )
{
throw new CommandLineConfigurationException( e.getMessage(), e );
}
File mvn = null;
try
{
mvn = findMavenExecutable();
}
catch ( IOException e )
{
throw new CommandLineConfigurationException( e.getMessage(), e );
}
Commandline cli = new Commandline();
cli.setExecutable( mvn.getAbsolutePath() );
// handling for OS-level envars
setShellEnvironment( request, cli );
// interactive, offline, update-snapshots,
// debug/show-errors, checksum policy
setFlags( request, cli );
// failure behavior and [eventually] forced-reactor
// includes/excludes, etc.
setReactorBehavior( request, cli );
// working directory and local repository location
setEnvironmentPaths( request, cli );
// pom-file and basedir handling
setPomLocation( request, cli );
setSettingsLocation( request, cli );
setToolchainsLocation( request, cli );
setProperties( request, cli );
setProfiles( request, cli );
setGoals( request, cli );
setThreads( request, cli );
return cli;
}
protected void checkRequiredState()
throws IOException
{
if ( logger == null )
{
throw new IllegalStateException( "A logger instance is required." );
}
if ( ( mavenHome == null ) && ( System.getProperty( "maven.home" ) == null ) )
// can be restored with 1.5
// && ( System.getenv( "M2_HOME" ) != null ) )
{
if ( !getSystemEnvVars().containsKey( "M2_HOME" ) )
{
throw new IllegalStateException( "Maven application directory was not "
+ "specified, and ${maven.home} is not provided in the system "
+ "properties. Please specify at least on of these." );
}
}
}
protected void setSettingsLocation( InvocationRequest request, Commandline cli )
{
File userSettingsFile = request.getUserSettingsFile();
if ( userSettingsFile != null )
{
try
{
File canSet = userSettingsFile.getCanonicalFile();
userSettingsFile = canSet;
}
catch ( IOException e )
{
logger.debug( "Failed to canonicalize user settings path: " + userSettingsFile.getAbsolutePath()
+ ". Using as-is.", e );
}
cli.createArg().setValue( "-s" );
cli.createArg().setValue( userSettingsFile.getPath() );
}
File globalSettingsFile = request.getGlobalSettingsFile();
if ( globalSettingsFile != null )
{
try
{
File canSet = globalSettingsFile.getCanonicalFile();
globalSettingsFile = canSet;
}
catch ( IOException e )
{
logger.debug( "Failed to canonicalize global settings path: " + globalSettingsFile.getAbsolutePath()
+ ". Using as-is.", e );
}
cli.createArg().setValue( "-gs" );
cli.createArg().setValue( globalSettingsFile.getPath() );
}
}
protected void setToolchainsLocation( InvocationRequest request, Commandline cli )
{
File toolchainsFile = request.getToolchainsFile();
if ( toolchainsFile != null )
{
try
{
File canSet = toolchainsFile.getCanonicalFile();
toolchainsFile = canSet;
}
catch ( IOException e )
{
logger.debug( "Failed to canonicalize toolchains path: " + toolchainsFile.getAbsolutePath()
+ ". Using as-is.", e );
}
cli.createArg().setValue( "-t" );
cli.createArg().setValue( toolchainsFile.getPath() );
}
}
protected void setShellEnvironment( InvocationRequest request, Commandline cli )
throws CommandLineConfigurationException
{
if ( request.isShellEnvironmentInherited() )
{
try
{
cli.addSystemEnvironment();
cli.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );
}
catch ( IOException e )
{
throw new CommandLineConfigurationException( "Error reading shell environment variables. Reason: "
+ e.getMessage(), e );
}
catch ( Exception e )
{
if ( e instanceof RuntimeException )
{
throw (RuntimeException) e;
}
else
{
IllegalStateException error =
new IllegalStateException( "Unknown error retrieving shell environment variables. Reason: "
+ e.getMessage() );
error.initCause( e );
throw error;
}
}
}
if ( request.getJavaHome() != null )
{
cli.addEnvironment( "JAVA_HOME", request.getJavaHome().getAbsolutePath() );
}
if ( request.getMavenOpts() != null )
{
cli.addEnvironment( "MAVEN_OPTS", request.getMavenOpts() );
}
for ( Map.Entrynull
.
*/
private PrintStream out;
/**
* The threshold used to filter messages.
*/
private int threshold;
/**
* Creates a new logger that writes to {@link System#out} and has a threshold of {@link #INFO}.
*/
public PrintStreamLogger()
{
this( System.out, INFO );
}
/**
* Creates a new logger that writes to the specified print stream.
*
* @param out The print stream to write to, must not be null
.
* @param threshold The threshold for the logger.
*/
public PrintStreamLogger( PrintStream out, int threshold )
{
if ( out == null )
{
throw new NullPointerException( "missing output stream" );
}
this.out = out;
setThreshold( threshold );
}
/**
* Writes the specified message and exception to the print stream.
*
* @param level The priority level of the message.
* @param message The message to log, may be null
.
* @param error The exception to log, may be null
.
*/
private void log( int level, String message, Throwable error )
{
if ( level > threshold )
{
// don't log when it doesn't match your threshold.
return;
}
if ( message == null && error == null )
{
// don't log when there's nothing to log.
return;
}
StringBuffer buffer = new StringBuffer();
switch ( level )
{
case ( DEBUG ):
{
buffer.append( "[DEBUG]" );
break;
}
case ( INFO ):
{
buffer.append( "[INFO]" );
break;
}
case ( WARN ):
{
buffer.append( "[WARN]" );
break;
}
case ( ERROR ):
{
buffer.append( "[ERROR]" );
break;
}
case ( FATAL ):
{
buffer.append( "[FATAL]" );
break;
}
}
buffer.append( ' ' );
if ( message != null )
{
buffer.append( message );
}
if ( error != null )
{
StringWriter writer = new StringWriter();
PrintWriter pWriter = new PrintWriter( writer );
error.printStackTrace( pWriter );
if ( message != null )
{
buffer.append( '\n' );
}
buffer.append( "Error:\n" );
buffer.append( writer.toString() );
}
out.println( buffer.toString() );
}
public void debug( String message )
{
log( DEBUG, message, null );
}
public void debug( String message, Throwable throwable )
{
log( DEBUG, message, throwable );
}
public void info( String message )
{
log( INFO, message, null );
}
public void info( String message, Throwable throwable )
{
log( INFO, message, throwable );
}
public void warn( String message )
{
log( WARN, message, null );
}
public void warn( String message, Throwable throwable )
{
log( WARN, message, throwable );
}
public void error( String message )
{
log( ERROR, message, null );
}
public void error( String message, Throwable throwable )
{
log( ERROR, message, throwable );
}
public void fatalError( String message )
{
log( FATAL, message, null );
}
public void fatalError( String message, Throwable throwable )
{
log( FATAL, message, throwable );
}
public boolean isDebugEnabled()
{
return threshold >= DEBUG;
}
public boolean isErrorEnabled()
{
return threshold >= ERROR;
}
public boolean isFatalErrorEnabled()
{
return threshold >= FATAL;
}
public boolean isInfoEnabled()
{
return threshold >= INFO;
}
public boolean isWarnEnabled()
{
return threshold >= WARN;
}
public int getThreshold()
{
return threshold;
}
public void setThreshold( int threshold )
{
this.threshold = threshold;
}
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/InvokerLogger.java 0000664 0001750 0001750 00000013042 11020276126 027740 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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.
*/
/**
* A logger used by {@link Invoker} instances to output diagnostic messages.
*
* @see Invoker#setLogger(InvokerLogger)
* @author Jason van Zyl
* @version $Id: InvokerLogger.java 662043 2008-05-31 16:27:02Z bentmann $
*/
public interface InvokerLogger
{
/**
* The threshold for debug output.
*/
public static final int DEBUG = 4;
/**
* The threshold for info output.
*/
public static final int INFO = 3;
/**
* The threshold for warn output.
*/
public static final int WARN = 2;
/**
* The threshold for error output.
*/
public static final int ERROR = 1;
/**
* The threshold for fatal error output.
*/
public static final int FATAL = 0;
/**
* Logs the specified debug message.
*
* @param message The message to log, may be null
.
*/
void debug( String message );
/**
* Logs the specified debug message and the accompanying exception.
*
* @param message The message to log, may be null
.
* @param throwable The exception to log, may be null
.
*/
void debug( String message, Throwable throwable );
/**
* Tests whether debug output is enabled for this logger.
*
* @return true
if messages with priority "debug" or above are logged, false
* otherwise.
*/
boolean isDebugEnabled();
/**
* Logs the specified info message.
*
* @param message The message to log, may be null
.
*/
void info( String message );
/**
* Logs the specified info message and the accompanying exception.
*
* @param message The message to log, may be null
.
* @param throwable The exception to log, may be null
.
*/
void info( String message, Throwable throwable );
/**
* Tests whether info output is enabled for this logger.
*
* @return true
if messages with priority "info" or above are logged, false
otherwise.
*/
boolean isInfoEnabled();
/**
* Logs the specified warning message.
*
* @param message The message to log, may be null
.
*/
void warn( String message );
/**
* Logs the specified warning message and the accompanying exception.
*
* @param message The message to log, may be null
.
* @param throwable The exception to log, may be null
.
*/
void warn( String message, Throwable throwable );
/**
* Tests whether warn output is enabled for this logger.
*
* @return true
if messages with priority "warn" or above are logged, false
otherwise.
*/
boolean isWarnEnabled();
/**
* Logs the specified error message.
*
* @param message The message to log, may be null
.
*/
void error( String message );
/**
* Logs the specified error message and the accompanying exception.
*
* @param message The message to log, may be null
.
* @param throwable The exception to log, may be null
.
*/
void error( String message, Throwable throwable );
/**
* Tests whether error output is enabled for this logger.
*
* @return true
if messages with priority "error" or above are logged, false
* otherwise.
*/
boolean isErrorEnabled();
/**
* Logs the specified fatal error message.
*
* @param message The message to log, may be null
.
*/
void fatalError( String message );
/**
* Logs the specified fatal error message and the accompanying exception.
*
* @param message The message to log, may be null
.
* @param throwable The exception to log, may be null
.
*/
void fatalError( String message, Throwable throwable );
/**
* Tests whether fatal error output is enabled for this logger.
*
* @return true
if messages with priority "fatal" or above are logged, false
* otherwise.
*/
boolean isFatalErrorEnabled();
/**
* Sets the logger's threshold.
*
* @param threshold The logger's threshold, must be one of {@link #DEBUG}, {@link #INFO}, {@link #WARN},
* {@link #ERROR} and {@link #FATAL}.
*/
void setThreshold( int threshold );
/**
* Gets the logger's threshold.
*
* @return The logger's threshold, one of {@link #DEBUG}, {@link #INFO}, {@link #WARN}, {@link #ERROR} and
* {@link #FATAL}.
*/
int getThreshold();
}
maven-invoker-2.1.1/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java 0000664 0001750 0001750 00000062064 12034352202 030651 0 ustar ebourg ebourg package org.apache.maven.shared.invoker;
/*
* 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 java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* Specifies the parameters used to control a Maven invocation.
*
* @version $Id: InvocationRequest.java 1395369 2012-10-07 19:14:10Z rfscholte $
*/
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.
*
* @return true
if Maven should be executed in interactive mode, false
if the batch
* mode is used.
*/
boolean isInteractive();
/**
* Gets the network mode of the Maven invocation. By default, Maven is executed in online mode.
*
* @return true
if Maven should be executed in offline mode, false
if the online mode
* is used.
*/
boolean isOffline();
/**
* Indicates whether Maven should enforce an update check for plugins and snapshots. By default, no update check is
* performed.
*
* @return true
if plugins and snapshots should be updated, false
otherwise.
*/
boolean isUpdateSnapshots();
/**
* Gets the recursion behavior of a reactor invocation. By default, Maven will recursive the build into sub modules.
*
* @return true
if sub modules should be build, false
otherwise.
*/
boolean isRecursive();
/**
* Gets whether Maven should search subdirectories to build a dynamic reactor
* @return true
if we should search subdirectories, false
otherwise
*/
public boolean isActivatedReactor();
/**
* Gets the list of subdirectory patterns to search
* @return list of subdirectory patterns to search, or null
in which case defaults should be used
*/
public String[] getActivatedReactorIncludes();
/**
* Gets the list of subdirectory patterns to exclude from search
* @return list of subdirectory patterns to exclude search, or null
in which case nothing should be excluded
*/
public 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.
*
* @return the list of projects to add to reactor build, otherwise {@code null}
* @since 2.1
*/
public Listtrue
if Maven should be executed in debug mode, false
if the normal mode
* should be used.
*/
boolean isDebug();
/**
* Gets the exception output mode of the Maven invocation. By default, Maven will not print stack traces of build
* exceptions.
*
* @return true
if Maven should print stack traces, false
otherwise.
*/
boolean isShowErrors();
/**
* Indicates whether the environment variables of the current process should be propagated to the Maven invocation.
* By default, the current environment variables are inherited by the new Maven invocation.
*
* @return true
if the environment variables should be propagated, false
otherwise.
*/
boolean isShellEnvironmentInherited();
/**
* Indicates whether Maven should check for plugin updates. By default, plugin updates are not suppressed.
*
* @return true
if plugin updates should be suppressed, false
otherwise.
*/
boolean isNonPluginUpdates();
/**
* Gets the failure mode of the Maven invocation. By default, the mode {@link #REACTOR_FAIL_FAST} is used.
*
* @return The failure mode, one of {@link #REACTOR_FAIL_FAST}, {@link #REACTOR_FAIL_AT_END} and
* {@link #REACTOR_FAIL_NEVER}.
*/
String getFailureBehavior();
/**
* 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
* null
.
* @return The path to the base directory of the local repository or null
to use the location from
* the settings.xml
.
*/
File getLocalRepositoryDirectory( File defaultDirectory );
/**
* Gets the input stream used to provide input for the invoked Maven build. This is in particular useful when
* invoking Maven in interactive mode.
*
* @return The input stream used to provide input for the invoked Maven build or null
if not set.
*/
InputStream getInputStream( InputStream defaultStream );
/**
* Gets the handler used to capture the standard output from the Maven build.
*
* @return The output handler or null
if not set.
*/
InvocationOutputHandler getOutputHandler( InvocationOutputHandler defaultHandler );
/**
* Gets the handler used to capture the error output from the Maven build.
*
* @return The error handler or null
if not set.
*/
InvocationOutputHandler getErrorHandler( InvocationOutputHandler defaultHandler );
/**
* Gets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM
* will be used as the working directory for the Maven invocation.
*
* @return The path to the POM for the Maven invocation or null
if not set.
*/
File getPomFile();
/**
* Gets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if
* {@link #getPomFile()} does not return null
. Otherwise, the base directory is assumed to contain a
* POM with this name. By default, a file named pom.xml
is used.
*
* @return The (unqualified) filename of the POM for the Maven invocation or null
if not set.
*/
String getPomFileName();
/**
* Gets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return
* null
, this setting only affects the working directory for the Maven invocation.
*
* @return The path to the base directory of the POM or null
if not set.
*/
File getBaseDirectory();
/**
* Gets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return
* null
, this setting only affects the working directory for the Maven invocation.
*
* @param defaultDirectory The default base directory to use if none is configured for this request, may be
* null
.
* @return The path to the base directory of the POM or null
if not set.
*/
File getBaseDirectory( File defaultDirectory );
/**
* 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 null
to use
* the default Java home.
*/
File getJavaHome();
/**
* Gets the system properties for the Maven invocation.
*
* @return The system properties for the Maven invocation or null
if not set.
*/
Properties getProperties();
/**
* Gets the goals for the Maven invocation.
*
* @return The goals for the Maven invocation or null
if not set.
*/
Listnull
to load the user settings
* from the default location.
*/
File getUserSettingsFile();
/**
* Gets the path to the global settings for the Maven invocation.
*
* @return The path to the global settings for the Maven invocation or null
to load the global settings
* from the default location.
* @since 2.1
*/
File getGlobalSettingsFile();
/**
* Gets the path to the custom toolchains file
*
* @return The path to the custom toolchains file or null
to load the toolchains from the default location
* @since 2.1
*/
File getToolchainsFile();
/**
* Gets the checksum mode of the Maven invocation.
*
* @return The checksum mode, one of {@link #CHECKSUM_POLICY_WARN} and {@link #CHECKSUM_POLICY_FAIL}.
*/
String getGlobalChecksumPolicy();
/**
* Gets the profiles for the Maven invocation.
*
* @return The profiles for the Maven invocation or null
if not set.
*/
Listnull
if not set.
*/
MapMAVEN_OPTS
environment variable.
*
* @return The value of the MAVEN_OPTS
environment variable or null
if not set.
*/
String getMavenOpts();
/**
* The show version behaviour (-V option)
* @return The show version behaviour
* @since 2.0.11
*/
boolean isShowVersion();
/**
* Get the value of the {@code threads} argument.
*
* @return the value of the {@code threads} argument or {@code null} if not set
* @since 2.1
*/
String getThreads();
// ----------------------------------------------------------------------
// Reactor Failure Mode
// ----------------------------------------------------------------------
/**
* The failure mode "fail-fast" where the build is stopped by the first failure.
*/
static final String REACTOR_FAIL_FAST = "fail-fast";
/**
* The failure mode "fail-at-end" where the build is only failed at its very end if necessary.
*/
static final String REACTOR_FAIL_AT_END = "fail-at-end";
/**
* The failure mode "fail-never" in which Maven will always exit with code 0 regardless of build failures.
*/
static final String REACTOR_FAIL_NEVER = "fail-never";
// ----------------------------------------------------------------------
// Artifact repository policies
// ----------------------------------------------------------------------
/**
* The strict checksum policy which fails the build if a corrupt artifact is detected.
*/
static final String CHECKSUM_POLICY_FAIL = "fail";
/**
* The lax checksum policy which only outputs a warning if a corrupt artifact is detected.
*/
static final String CHECKSUM_POLICY_WARN = "warn";
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
/**
* Sets the interaction mode of the Maven invocation.
* Inverse equivalent of {@code -B} and {@code --batch-mode}
*
* @param interactive true
if Maven should be executed in interactive mode, false
if
* the batch mode is used.
* @return This invocation request.
*/
InvocationRequest setInteractive( boolean interactive );
/**
* Sets the network mode of the Maven invocation.
* Equivalent of {@code -o} and {@code --offline}
*
* @param offline true
if Maven should be executed in offline mode, false
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}
*
* @param debug true
if Maven should be executed in debug mode, false
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}
*
* @param showErrors true
if Maven should print stack traces, false
otherwise.
* @return This invocation request.
*/
InvocationRequest setShowErrors( boolean showErrors );
/**
* Specifies whether Maven should enforce an update check for plugins and snapshots.
* Equivalent of {@code -U} and {@code --update-snapshots}
*
* @param updateSnapshots true
if plugins and snapshots should be updated, false
* otherwise.
* @return This invocation request.
*/
InvocationRequest setUpdateSnapshots( boolean updateSnapshots );
/**
* 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}.
* @return This invocation request.
*/
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 );
/**
* Sets the path to the base directory of the local repository to use for the Maven invocation.
*
* @param localRepository The path to the base directory of the local repository, may be null
.
* @return This invocation request.
*/
InvocationRequest setLocalRepositoryDirectory( File localRepository );
/**
* Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when
* invoking Maven in interactive mode.
*
* @param inputStream The input stream used to provide input for the invoked Maven build, may be null
* if not required.
* @return This invocation request.
*/
InvocationRequest setInputStream( InputStream inputStream );
/**
* Sets the handler used to capture the standard output from the Maven build.
*
* @param outputHandler The output handler, may be null
if the output is not of interest.
* @return This invocation request.
*/
InvocationRequest setOutputHandler( InvocationOutputHandler outputHandler );
/**
* Sets the handler used to capture the error output from the Maven build.
*
* @param errorHandler The error handler, may be null
if the output is not of interest.
* @return This invocation request.
*/
InvocationRequest setErrorHandler( InvocationOutputHandler errorHandler );
/**
* Sets the path to the POM for the Maven invocation. If no base directory is set, the parent directory of this POM
* will be used as the working directory for the Maven invocation.
*
* @param pomFile The path to the POM for the Maven invocation, may be null
if not used.
* @return This invocation request.
*/
InvocationRequest setPomFile( File pomFile );
/**
* Sets the (unqualified) filename of the POM for the Maven invocation. This setting is ignored if
* {@link #getPomFile()} does not return null
. Otherwise, the base directory is assumed to contain a
* POM with this name.
*
* @param pomFilename The (unqualified) filename of the POM for the Maven invocation, may be null
if
* not used.
* @return This invocation request.
*/
InvocationRequest setPomFileName( String pomFilename );
/**
* Sets the path to the base directory of the POM for the Maven invocation. If {@link #getPomFile()} does not return
* null
, this setting only affects the working directory for the Maven invocation.
*
* @param basedir The path to the base directory of the POM, may be null
if not used.
* @return This invocation request.
*/
InvocationRequest setBaseDirectory( File basedir );
/**
* Sets the path to the base directory of the Java installation used to run Maven.
*
* @param javaHome The path to the base directory of the Java installation used to run Maven, may be
* null
to use the default Java home.
* @return This invocation request.
*/
InvocationRequest setJavaHome( File javaHome );
/**
* Sets the system properties for the Maven invocation.
*
* @param properties The system properties for the Maven invocation, may be null
if not set.
* @return This invocation request.
*/
InvocationRequest setProperties( Properties properties );
/**
* Sets the goals for the Maven invocation.
*
* @param goals The goals for the Maven invocation, may be null
to execute the POMs default goal.
* @return This invocation request.
*/
InvocationRequest setGoals( Listnull
to use the default profiles.
* @return This invocation request.
*/
InvocationRequest setProfiles( Listtrue
if the environment variables should be propagated,
* false
otherwise.
* @return This invocation request.
*/
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 null
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}
*
* @param globalSettings The path to the global settings for the Maven invocation, may be null
to load
* the global settings from the default location.
* @return This invocation request.
* @since 2.1
*/
InvocationRequest setGlobalSettingsFile( File globalSettings );
/**
* Sets the alternate path for the user toolchains file
* Equivalent of {@code -t} or {@code --toolchains}
* * note: available since Maven3 *
* * @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} * * @param globalChecksumPolicy The checksum mode, must be one of {@link #CHECKSUM_POLICY_WARN} and * {@link #CHECKSUM_POLICY_FAIL}. * @return This invocation request. */ InvocationRequest setGlobalChecksumPolicy( String globalChecksumPolicy ); /** * Specifies whether Maven should check for plugin updates. *
* Equivalent of {@code -npu} or {@code --no-plugin-updates}
* note: Ineffective with Maven3, only kept for backward compatibility
*
true
if plugin updates should be suppressed, false
* otherwise.
* @return This invocation request.
*/
InvocationRequest setNonPluginUpdates( boolean nonPluginUpdates );
/**
* Sets the recursion behavior of a reactor invocation.
* Inverse equivalent of {@code -N} and {@code --non-recursive}
*
* @param recursive true
if sub modules should be build, false
otherwise.
* @return This invocation request.
*/
InvocationRequest setRecursive( boolean recursive );
/**
* Adds the specified environment variable to the Maven invocation.
*
* @param name The name of the environment variable, must not be null
.
* @param value The value of the environment variable, must not be null
.
* @return This invocation request.
*/
InvocationRequest addShellEnvironment( String name, String value );
/**
* Sets the value of the MAVEN_OPTS
environment variable.
*
* @param mavenOpts The value of the MAVEN_OPTS
environment variable, may be null
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}
*
* @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}
* * note: available since Maven3 *
* * @param threads the threadcount * @return This invocation request. * @since 2.1 */ InvocationRequest setThreads( String threads ); /** * Sets the reactor project list. * Equivalent of {@code -P} or {@code --projects} * * @param projects the reactor project list * @return This invocation request. * @since 2.1 */ InvocationRequest setProjects( List