1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.shared.scriptinterpreter; 20 21 import java.io.PrintStream; 22 import java.util.List; 23 import java.util.Map; 24 25 /** 26 * Defines a simple abstraction used to plug-in several script interpreters for the pre-/post-build-hooks. Each 27 * interpreter implementation should be stateless and support reuse. 28 * 29 * @author Benjamin Bentmann 30 */ 31 public interface ScriptInterpreter { 32 33 /** 34 * Evaluates the specified script. 35 * 36 * @param script The script contents to evaluate, must not be <code>null</code>. 37 * @param classPath The additional class path for the script interpreter, may be <code>null</code> or empty if only 38 * the plugin realm should be used for the script evaluation. If specified, this class path will precede 39 * the artifacts from the plugin class path. 40 * @param globalVariables The global variables (as a mapping from variable name to value) to define for the script, 41 * may be <code>null</code> if not used. 42 * @param scriptOutput A print stream to redirect any output from the script to, may be <code>null</code> to use 43 * stdout/stderr. 44 * @return The return value from the script, can be <code>null</code> 45 * @throws ScriptEvaluationException If the script evaluation produced an error. 46 */ 47 Object evaluateScript( 48 String script, 49 List<String> classPath, 50 Map<String, ? extends Object> globalVariables, 51 PrintStream scriptOutput) 52 throws ScriptEvaluationException; 53 }