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