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