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 import org.apache.maven.shared.utils.cli.CommandLineException;
22 import org.apache.maven.shared.utils.cli.Commandline;
23
24 /**
25 * Describes the result of a {@link JavaTool} invocation.
26 *
27 * @author <a href="mailto:chemit@codelutin.com">Tony Chemit</a>
28 * @since 0.5
29 */
30 public class JavaToolResult {
31 /**
32 * The exception that prevented to execute the command line, will be <code>null</code> if jarSigner could be
33 * successfully started.
34 */
35 private CommandLineException executionException;
36
37 /**
38 * The exit code reported by the Maven invocation.
39 */
40 private int exitCode = Integer.MIN_VALUE;
41
42 /**
43 * The command line used to obtain this result.
44 */
45 private Commandline commandline;
46
47 /**
48 * Gets the exit code from the tool invocation. A non-zero value indicates a build failure. <strong>Note:</strong>
49 * This value is undefined if {@link #getExecutionException()} reports an exception.
50 *
51 * @return The exit code from the tool invocation.
52 */
53 public int getExitCode() {
54 return exitCode;
55 }
56
57 /**
58 * Gets the command line used.
59 *
60 * @return The command line used
61 */
62 public Commandline getCommandline() {
63 return commandline;
64 }
65
66 /**
67 * Gets the exception that possibly occurred during the execution of the command line.
68 *
69 * @return The exception that prevented to invoke tool or <code>null</code> if the command line was successfully
70 * processed by the operating system.
71 */
72 public CommandLineException getExecutionException() {
73 return executionException;
74 }
75
76 /**
77 * Sets the exit code reported by the tool invocation.
78 *
79 * @param exitCode The exit code reported by the tool invocation.
80 */
81 public void setExitCode(int exitCode) {
82 this.exitCode = exitCode;
83 }
84
85 /**
86 * Sets the exception that prevented to execute the command line.
87 *
88 * @param executionException The exception that prevented to execute the command line, may be <code>null</code>.
89 */
90 public void setExecutionException(CommandLineException executionException) {
91 this.executionException = executionException;
92 }
93
94 /**
95 * Set the commandline used to obtain this result.
96 *
97 * @param commandline the commandline used to obtain this result
98 */
99 public void setCommandline(Commandline commandline) {
100 this.commandline = commandline;
101 }
102 }