@@ -43,8 +43,12 @@ public class JavaExecutionFunction extends MCPFunction {
43
43
/**
44
44
* Constructs a new java execution function with the given name, input and output.
45
45
*
46
- * @param name The name of the function
47
- * @param output The output of the function
46
+ * @param name The name of the function
47
+ * @param output The output of the function
48
+ * @param executionArtifact The artifact to execute
49
+ * @param artifactRepository The repository to retrieve the artifact from if it is missing
50
+ * @param args The arguments to pass to the executable
51
+ * @param jvmArgs The arguments to pass to the JVM executing the executable
48
52
*/
49
53
public JavaExecutionFunction (
50
54
String name ,
@@ -67,31 +71,31 @@ public JavaExecutionFunction(
67
71
@ Override
68
72
public void prepare (DeobfuscationUtilities utilities ) throws DeobfuscationException {
69
73
SimpleMavenRepository localRepository = utilities .getInternalRepository ();
70
- if (!localRepository .isInstalled (executionArtifact )) {
74
+ if (!localRepository .isInstalled (executionArtifact )) {
71
75
// Retrieve utilities
72
76
MavenArtifactDownloader downloader = utilities .getDownloader ();
73
77
74
78
// The artifact is not installed already, install it
75
- if (artifactRepository == null ) {
79
+ if (artifactRepository == null ) {
76
80
// Can't download anything in offline mode
77
81
throw new DeobfuscationException ("Missing artifact " + executionArtifact + " in local repository, " +
78
82
"but working in offline mode" );
79
83
}
80
84
81
85
boolean setupSource = !downloader .hasSource (artifactRepository );
82
- if (setupSource ) {
86
+ if (setupSource ) {
83
87
// The download has the source not set already, add it now
84
88
downloader .addSource (artifactRepository );
85
89
}
86
90
87
91
try {
88
92
// Install the artifact including dependencies
89
93
downloader .installAll (executionArtifact , localRepository , true );
90
- } catch (IOException | MavenResolveException e ) {
94
+ } catch (IOException | MavenResolveException e ) {
91
95
throw new DeobfuscationException ("Failed to install execution artifact" , e );
92
96
}
93
97
94
- if (setupSource ) {
98
+ if (setupSource ) {
95
99
// We added the source, clean up afterwards
96
100
downloader .removeSource (artifactRepository );
97
101
}
@@ -118,18 +122,18 @@ public void execute(DeobfuscationUtilities utilities) throws DeobfuscationExcept
118
122
args ,
119
123
jvmArgs
120
124
);
121
- } catch (IOException e ) {
125
+ } catch (IOException e ) {
122
126
// This happens if the execution fails, but has nothing to do with the exit code
123
127
throw new DeobfuscationException ("Failed to execute java process for function " + name );
124
128
}
125
129
126
- if (result .getExitCode () != 0 ) {
130
+ if (result .getExitCode () != 0 ) {
127
131
// The process failed to execute properly
128
132
Path standardOutput ;
129
133
try {
130
134
// Try to save the standard output
131
135
standardOutput = saveOutput ("stdout" , result .getStdout ());
132
- } catch (IOException e ) {
136
+ } catch (IOException e ) {
133
137
throw new DeobfuscationException ("Failed to save standard output after process failed, " +
134
138
"some is very wrong" , e );
135
139
}
@@ -138,7 +142,7 @@ public void execute(DeobfuscationUtilities utilities) throws DeobfuscationExcept
138
142
try {
139
143
// Try to save the standard error
140
144
standardError = saveOutput ("stderr" , result .getStderr ());
141
- } catch (IOException e ) {
145
+ } catch (IOException e ) {
142
146
throw new DeobfuscationException ("Failed to save standard error after process failed, " +
143
147
"some is very wrong" , e );
144
148
}
0 commit comments