1package org.apache.maven.shared.invoker;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import java.io.File;
23import java.io.InputStream;
2425/**26 * Provides a facade to invoke Maven.27 * 28 * @version $Id: Invoker.java 1395172 2012-10-06 21:15:33Z rfscholte $29 */30publicinterfaceInvoker31 {
3233/**34 * The role name used to register implementations of this interface within Plexus.35 */36 String ROLE = Invoker.class.getName();
3738/**39 * @deprecated Query this property by yourself, this has nothing to do with invoking Maven and as such does not40 * belong into this API!41 */42 String userHome = System.getProperty( "user.home" );
4344/**45 * Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the46 * invocation request will be derived from the state of this invoker instance. In case both the invoker instance and47 * the invocation request provide a value for a particular option, the value from the invocation request dominates.48 * 49 * @param request The invocation request to execute, must not be <code>null</code>.50 * @return The result of the Maven invocation, never <code>null</code>.51 * @throws MavenInvocationException52 */53InvocationResult execute( InvocationRequest request )
54throws MavenInvocationException;
5556/**57 * Gets the path to the base directory of the local repository to use for the Maven invocation.58 * 59 * @return The path to the base directory of the local repository or <code>null</code> to use the location from60 * the <code>settings.xml</code>.61 */62 File getLocalRepositoryDirectory();
6364/**65 * Gets the working directory for the Maven invocation.66 * 67 * @return The working directory for the Maven invocation or <code>null</code> if the working directory is derived68 * from the base directory of the processed POM.69 */70 File getWorkingDirectory();
7172/**73 * Gets the logger used by this invoker to output diagnostic messages.74 * 75 * @return The logger used by this invoker to output diagnostic messages, never <code>null</code>.76 */77InvokerLogger getLogger();
7879/**80 * Gets the path to the base directory of the Maven installation used to invoke Maven.81 * 82 * @return The path to the base directory of the Maven installation or <code>null</code> if using the default83 * Maven installation.84 */85 File getMavenHome();
8687/**88 * Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left89 * unspecified to use the default Maven installation which will be discovered by evaluating the system property90 * <code>maven.home</code> and the environment variable <code>M2_HOME</code>.91 * 92 * @param mavenHome The path to the base directory of the Maven installation, may be <code>null</code> to use the93 * default Maven installation.94 * @return This invoker instance.95 */96Invoker setMavenHome( File mavenHome );
9798/**99 * Get the customized File of the Maven executable.100 * 101 * @return the custom Maven executable, otherwise {@code null} 102 */103 File getMavenExecutable();
104105/**106 * {@code mavenExecutable} can either be a file relative to ${maven.home}/bin/ or an absolute file.107 * 108 * @param mavenExecutable the executable109 * @return This invoker instance110 */111Invoker setMavenExecutable( File mavenExecutable );
112113/**114 * Sets the path to the base directory of the local repository to use for the Maven invocation.115 * 116 * @param localRepositoryDirectory The path to the base directory of the local repository or <code>null</code> to117 * use the location from the <code>settings.xml</code>.118 * @return This invoker instance.119 */120Invoker setLocalRepositoryDirectory( File localRepositoryDirectory );
121122/**123 * Sets the logger used by this invoker to output diagnostic messages.124 * 125 * @param logger The logger used by this invoker to output diagnostic messages, may be <code>null</code> to use a126 * default logger.127 * @return This invoker instance.128 */129Invoker setLogger( InvokerLogger logger );
130131/**132 * Sets the working directory for the Maven invocation.133 * 134 * @param workingDirectory The working directory for the Maven invocation, may be <code>null</code> to derive the135 * working directory from the base directory of the processed POM.136 * @return This invoker instance.137 */138Invoker setWorkingDirectory( File workingDirectory );
139140/**141 * Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when142 * invoking Maven in interactive mode.143 * 144 * @param inputStream The input stream used to provide input for the invoked Maven build, may be <code>null</code>145 * if not required.146 * @return This invoker instance.147 */148Invoker setInputStream( InputStream inputStream );
149150/**151 * Sets the handler used to capture the standard output from the Maven build.152 * 153 * @param outputHandler The output handler, may be <code>null</code> if the output is not of interest.154 * @return This invoker instance.155 */156Invoker setOutputHandler( InvocationOutputHandler outputHandler );
157158/**159 * Sets the handler used to capture the error output from the Maven build.160 * 161 * @param errorHandler The error handler, may be <code>null</code> if the output is not of interest.162 * @return This invoker instance.163 */164Invoker setErrorHandler( InvocationOutputHandler errorHandler );
165 }