1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.simpligility.maven.plugins.android;
17
18 import com.android.ide.common.process.ProcessException;
19 import com.android.ide.common.process.ProcessResult;
20
21
22
23
24 class ProcessResultImplCopy implements ProcessResult
25 {
26 private final String mCommand;
27 private final int mExitValue;
28 private final Exception mFailure;
29 ProcessResultImplCopy( String command, int exitValue )
30 {
31 this( command, exitValue, null );
32 }
33 ProcessResultImplCopy( String command, Exception failure )
34 {
35 this( command, -1, failure );
36 }
37 ProcessResultImplCopy( String command, int exitValue, Exception failure )
38 {
39 mCommand = command;
40 mExitValue = exitValue;
41 mFailure = failure;
42 }
43 @Override
44 public ProcessResult assertNormalExitValue() throws ProcessException
45 {
46 if ( mExitValue != 0 )
47 {
48 throw new ProcessException(
49 String.format( "Return code %d for process '%s'", mExitValue, mCommand ) );
50 }
51 return this;
52 }
53 @Override
54 public int getExitValue()
55 {
56 return mExitValue;
57 }
58 @Override
59 public ProcessResult rethrowFailure() throws ProcessException
60 {
61 if ( mFailure != null )
62 {
63 throw new ProcessException( "", mFailure );
64 }
65 return this;
66 }
67 }