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