1 package org.apache.maven.shared.invoker; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.io.File; 23 import java.io.InputStream; 24 25 /** 26 * Provides a facade to invoke Maven. 27 * 28 * @version $Id: Invoker.java 1635406 2014-10-30 06:51:13Z hboutemy $ 29 */ 30 public interface Invoker 31 { 32 33 /** 34 * The role name used to register implementations of this interface within Plexus. 35 */ 36 String ROLE = Invoker.class.getName(); 37 38 /** 39 * @deprecated Query this property by yourself, this has nothing to do with invoking Maven and as such does not 40 * belong into this API! 41 */ 42 @SuppressWarnings( "checkstyle:constantname" ) 43 String userHome = System.getProperty( "user.home" ); 44 45 /** 46 * Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the 47 * invocation request will be derived from the state of this invoker instance. In case both the invoker instance and 48 * the invocation request provide a value for a particular option, the value from the invocation request dominates. 49 * 50 * @param request The invocation request to execute, must not be <code>null</code>. 51 * @return The result of the Maven invocation, never <code>null</code>. 52 * @throws MavenInvocationException 53 */ 54 InvocationResult execute( InvocationRequest request ) 55 throws MavenInvocationException; 56 57 /** 58 * Gets the path to the base directory of the local repository to use for the Maven invocation. 59 * 60 * @return The path to the base directory of the local repository or <code>null</code> to use the location from 61 * the <code>settings.xml</code>. 62 */ 63 File getLocalRepositoryDirectory(); 64 65 /** 66 * Gets the working directory for the Maven invocation. 67 * 68 * @return The working directory for the Maven invocation or <code>null</code> if the working directory is derived 69 * from the base directory of the processed POM. 70 */ 71 File getWorkingDirectory(); 72 73 /** 74 * Gets the logger used by this invoker to output diagnostic messages. 75 * 76 * @return The logger used by this invoker to output diagnostic messages, never <code>null</code>. 77 */ 78 InvokerLogger getLogger(); 79 80 /** 81 * Gets the path to the base directory of the Maven installation used to invoke Maven. 82 * 83 * @return The path to the base directory of the Maven installation or <code>null</code> if using the default 84 * Maven installation. 85 */ 86 File getMavenHome(); 87 88 /** 89 * Sets the path to the base directory of the Maven installation used to invoke Maven. This parameter may be left 90 * unspecified to use the default Maven installation which will be discovered by evaluating the system property 91 * <code>maven.home</code> and the environment variable <code>M2_HOME</code>. 92 * 93 * @param mavenHome The path to the base directory of the Maven installation, may be <code>null</code> to use the 94 * default Maven installation. 95 * @return This invoker instance. 96 */ 97 Invoker setMavenHome( File mavenHome ); 98 99 /** 100 * Get the customized File of the Maven executable. 101 * 102 * @return the custom Maven executable, otherwise {@code null} 103 */ 104 File getMavenExecutable(); 105 106 /** 107 * {@code mavenExecutable} can either be a file relative to ${maven.home}/bin/ or an absolute file. 108 * 109 * @param mavenExecutable the executable 110 * @return This invoker instance 111 */ 112 Invoker setMavenExecutable( File mavenExecutable ); 113 114 /** 115 * Sets the path to the base directory of the local repository to use for the Maven invocation. 116 * 117 * @param localRepositoryDirectory The path to the base directory of the local repository or <code>null</code> to 118 * use the location from the <code>settings.xml</code>. 119 * @return This invoker instance. 120 */ 121 Invoker setLocalRepositoryDirectory( File localRepositoryDirectory ); 122 123 /** 124 * Sets the logger used by this invoker to output diagnostic messages. 125 * 126 * @param logger The logger used by this invoker to output diagnostic messages, may be <code>null</code> to use a 127 * default logger. 128 * @return This invoker instance. 129 */ 130 Invoker setLogger( InvokerLogger logger ); 131 132 /** 133 * Sets the working directory for the Maven invocation. 134 * 135 * @param workingDirectory The working directory for the Maven invocation, may be <code>null</code> to derive the 136 * working directory from the base directory of the processed POM. 137 * @return This invoker instance. 138 */ 139 Invoker setWorkingDirectory( File workingDirectory ); 140 141 /** 142 * Sets the input stream used to provide input for the invoked Maven build. This is in particular useful when 143 * invoking Maven in interactive mode. 144 * 145 * @param inputStream The input stream used to provide input for the invoked Maven build, may be <code>null</code> 146 * if not required. 147 * @return This invoker instance. 148 */ 149 Invoker setInputStream( InputStream inputStream ); 150 151 /** 152 * Sets the handler used to capture the standard output from the Maven build. 153 * 154 * @param outputHandler The output handler, may be <code>null</code> if the output is not of interest. 155 * @return This invoker instance. 156 */ 157 Invoker setOutputHandler( InvocationOutputHandler outputHandler ); 158 159 /** 160 * Sets the handler used to capture the error output from the Maven build. 161 * 162 * @param errorHandler The error handler, may be <code>null</code> if the output is not of interest. 163 * @return This invoker instance. 164 */ 165 Invoker setErrorHandler( InvocationOutputHandler errorHandler ); 166 }