1 package org.apache.maven.shared.utils.cli.javatool; 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 /** 23 * <p>Describes a java tool, means a executable available in the jdk.</p> 24 * <p>The name of the tool ({@link #getJavaToolName()}) reflects the name of the executable that should exists as an 25 * executable in the jdk, like {@code jarsigner, keytool, javadoc, ...}.</p> 26 * <p>An abstract implementation of the {@link JavaTool} named {@link AbstractJavaTool} use the command line API to 27 * execute any user requests of this tool.</p> 28 * 29 * @author <a href="mailto:chemit@codelutin.com">Tony Chemit</a> 30 * @since 0.5 31 * @param <Request> Tool-specific request type 32 */ 33 public interface JavaTool<Request extends JavaToolRequest> 34 { 35 36 /** 37 * <p>Return the name of the java tool. This is exactly the name (without his extension) of the executable to 38 * find in the {@code jdk/bin} directory.</p> 39 * <p>For example: {@code jarsigner, keytool, javadoc, ...}</p> 40 * 41 * @return the name of the java tool. 42 */ 43 String getJavaToolName(); 44 45 /** 46 * Set an optional tool chain to find out the java tool executable location. 47 * 48 * @param toolchain optional tool chain to find out the java tool executable location. 49 * To avoid direct dependency on Maven core, this parameter is an Object that will be 50 * used as Toolchain through reflection 51 */ 52 void setToolchain( Object toolchain ); 53 54 /** 55 * <p>Execute the input request and then returns the result of the execution.</p> 56 * <p>If could not create the java tool invocation, a {@link JavaToolException} will be thrown.</p> 57 * <p>If execution fails, then the result will have a none-zero {@link JavaToolResult#getExitCode()} and his 58 * {@link JavaToolResult#getExecutionException()} will be filled with the error, otherwise the exist code will be 59 * zero.</p> 60 * 61 * @param request the request to perform 62 * @return the result of the tool execution 63 * @throws JavaToolException if could not create the java tool invocation 64 */ 65 JavaToolResult execute( Request request ) 66 throws JavaToolException; 67 }