View Javadoc
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   * @param <Request>
36   */
37  public interface JavaTool<Request extends JavaToolRequest>
38  {
39  
40      /**
41       * Return the name of the java tool. This is exactly the name (without his extension) of the executable to
42       * find in the {@code jdk/bin} directory.
43       * <p/>
44       * For example: {@code jarsigner, keytool, javadoc, ...}
45       *
46       * @return the name of the java tool.
47       */
48      String getJavaToolName();
49  
50      /**
51       * Set an optional tool chain to find out the java tool executable location.
52       *
53       * @param toolchain optional tool chain to find out the java tool executable location.
54       */
55      void setToolchain( Toolchain 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  }