@@ -46,13 +46,13 @@ private static String getClasspath(List<String> classpathEntries) {
46
46
return builder .toString ();
47
47
}
48
48
49
- public static boolean runBladeEngine (File prjFolder , String chapter ,
50
- String scene , boolean fullscreen ) throws IOException {
51
- List <String > args = new ArrayList <String >();
49
+ public static boolean runBladeEngine (File prjFolder , String chapter , String scene , boolean fullscreen )
50
+ throws IOException {
51
+ List <String > args = new ArrayList <>();
52
52
args .add (":desktop:run" );
53
53
String appArgs = "-PappArgs=['-d'" ;
54
-
55
- if (!fullscreen )
54
+
55
+ if (!fullscreen )
56
56
appArgs += ",'-w'" ;
57
57
58
58
if (chapter != null ) {
@@ -69,49 +69,45 @@ public static boolean runBladeEngine(File prjFolder, String chapter,
69
69
return runGradle (prjFolder , args );
70
70
}
71
71
72
- public static boolean runBladeEngineInternal (File prjFolder , String chapter ,
73
- String scene )
74
- throws IOException {
75
- List <String > args = new ArrayList <String >();
72
+ public static boolean runBladeEngineInternal (File prjFolder , String chapter , String scene ) throws IOException {
73
+ List <String > args = new ArrayList <>();
76
74
args .add ("-w" );
77
75
args .add ("-adv-dir" );
78
76
args .add (prjFolder .getAbsolutePath ());
79
-
80
- if (scene != null ) {
77
+
78
+ if (scene != null ) {
81
79
args .add ("-t" );
82
80
args .add (scene );
83
81
}
84
-
82
+
85
83
if (chapter != null ) {
86
84
args .add ("-chapter" );
87
85
args .add (chapter );
88
86
}
89
87
90
- List <String > cp = new ArrayList <String >();
88
+ List <String > cp = new ArrayList <>();
91
89
cp .add (System .getProperty ("java.class.path" ));
92
90
93
91
runJavaProccess ("com.bladecoder.engineeditor.utils.DesktopLauncher" , cp , args );
94
-
92
+
95
93
return true ;
96
94
}
97
95
98
- public static void runAnt (String buildFile , String target , String distDir ,
99
- String projectDir , Properties props ) throws IOException {
96
+ public static void runAnt (String buildFile , String target , String distDir , String projectDir , Properties props )
97
+ throws IOException {
100
98
String packageFilesDir = "package-files/" ;
101
99
102
100
if (!new File (packageFilesDir ).exists ()) {
103
- EditorLogger
104
- .error ("package-files folder not found. Searching folder for IDE mode." );
101
+ EditorLogger .error ("package-files folder not found. Searching folder for IDE mode." );
105
102
106
103
packageFilesDir = "src/dist/package-files/" ;
107
104
if (!new File (packageFilesDir ).exists ()) {
108
- EditorLogger .error (new File (packageFilesDir ).getAbsolutePath ()
109
- + " folder not found in IDE mode." );
105
+ EditorLogger .error (new File (packageFilesDir ).getAbsolutePath () + " folder not found in IDE mode." );
110
106
return ;
111
107
}
112
108
}
113
109
114
- List <String > args = new ArrayList <String >();
110
+ List <String > args = new ArrayList <>();
115
111
args .add ("-f" );
116
112
args .add (packageFilesDir + buildFile );
117
113
args .add ("-Dproject=" + projectDir );
@@ -127,7 +123,7 @@ public static void runAnt(String buildFile, String target, String distDir,
127
123
128
124
args .add (target );
129
125
130
- List <String > cp = new ArrayList <String >();
126
+ List <String > cp = new ArrayList <>();
131
127
// cp.add(System.getProperty("java.class.path") );
132
128
cp .add (packageFilesDir + "ant.jar" );
133
129
cp .add (packageFilesDir + "ant-launcher.jar" );
@@ -146,13 +142,12 @@ public static void runAnt(String buildFile, String target, String distDir,
146
142
}
147
143
}
148
144
149
- public static Process runJavaProccess (String mainClass ,
150
- List <String > classpathEntries , List <String > args )
145
+ public static Process runJavaProccess (String mainClass , List <String > classpathEntries , List <String > args )
151
146
throws IOException {
152
147
String javaRT = System .getProperty ("java.home" ) + "/bin/java" ;
153
148
String workingDirectory = "." ;
154
149
155
- List <String > argumentsList = new ArrayList <String >();
150
+ List <String > argumentsList = new ArrayList <>();
156
151
argumentsList .add (javaRT );
157
152
158
153
if (classpathEntries != null && classpathEntries .size () > 0 ) {
@@ -165,39 +160,66 @@ public static Process runJavaProccess(String mainClass,
165
160
if (args != null )
166
161
argumentsList .addAll (args );
167
162
168
- ProcessBuilder processBuilder = new ProcessBuilder (
169
- argumentsList .toArray (new String [argumentsList .size ()]));
163
+ ProcessBuilder processBuilder = new ProcessBuilder (argumentsList .toArray (new String [argumentsList .size ()]));
170
164
// processBuilder.redirectErrorStream(true);
171
165
processBuilder .directory (new File (workingDirectory ));
172
166
processBuilder .inheritIO ();
173
167
174
168
return processBuilder .start ();
175
169
}
176
-
177
- public static boolean runGradle (File workingDir , List <String > parameters ) {
178
- String exec = workingDir .getAbsolutePath ()
179
- + "/"
180
- + (System .getProperty ("os.name" ).contains ("Windows" ) ? "gradlew.bat"
181
- : "gradlew" );
182
-
183
- List <String > argumentsList = new ArrayList <String >();
170
+
171
+ public static boolean runGradle (File workingDir , List <String > parameters ) {
172
+ String exec = workingDir .getAbsolutePath () + "/"
173
+ + (System .getProperty ("os.name" ).contains ("Windows" ) ? "gradlew.bat" : "gradlew" );
174
+
175
+ List <String > argumentsList = new ArrayList <>();
184
176
argumentsList .add (exec );
185
177
argumentsList .addAll (parameters );
186
178
187
179
EditorLogger .msgThreaded ("Executing 'gradlew " + parameters + "'" );
188
180
189
181
try {
190
- final ProcessBuilder pb = new ProcessBuilder (argumentsList ).directory (
191
- workingDir ).redirectErrorStream (true );
182
+ final ProcessBuilder pb = new ProcessBuilder (argumentsList ).directory (workingDir ).redirectErrorStream (true );
192
183
193
184
// TODO: READ OUTPUT FROM pb AND print in output stream
194
185
// if (System.console() != null)
195
186
// pb.inheritIO();
196
187
197
188
final Process process = pb .start ();
198
189
199
- BufferedReader in = new BufferedReader (new InputStreamReader (
200
- process .getInputStream ()));
190
+ BufferedReader in = new BufferedReader (new InputStreamReader (process .getInputStream ()));
191
+ String line ;
192
+ while ((line = in .readLine ()) != null ) {
193
+ EditorLogger .msgThreaded (line );
194
+ }
195
+
196
+ process .waitFor ();
197
+ return process .exitValue () == 0 ;
198
+ } catch (Exception e ) {
199
+ EditorLogger .msgThreaded ("ERROR: " + e .getMessage ());
200
+ return false ;
201
+ }
202
+ }
203
+
204
+ public static boolean runInklecate (File workingDir , List <String > parameters ) {
205
+ String exec = workingDir .getAbsolutePath () + "/" + "inklecate.exe" ;
206
+
207
+ List <String > argumentsList = new ArrayList <>();
208
+ argumentsList .add (exec );
209
+ argumentsList .addAll (parameters );
210
+
211
+ EditorLogger .msgThreaded ("Executing 'inklecate " + parameters + "'" );
212
+
213
+ try {
214
+ final ProcessBuilder pb = new ProcessBuilder (argumentsList ).directory (workingDir ).redirectErrorStream (true );
215
+
216
+ // TODO: READ OUTPUT FROM pb AND print in output stream
217
+ // if (System.console() != null)
218
+ // pb.inheritIO();
219
+
220
+ final Process process = pb .start ();
221
+
222
+ BufferedReader in = new BufferedReader (new InputStreamReader (process .getInputStream ()));
201
223
String line ;
202
224
while ((line = in .readLine ()) != null ) {
203
225
EditorLogger .msgThreaded (line );
@@ -212,7 +234,7 @@ public static boolean runGradle(File workingDir, List<String> parameters) {
212
234
}
213
235
214
236
public static boolean runGradle (File workingDir , String parameters ) {
215
-
237
+
216
238
String [] split = parameters .split (" " );
217
239
218
240
return runGradle (workingDir , Arrays .asList (split ));
0 commit comments