@@ -339,29 +339,30 @@ private File signPackage(File projectFolder, String keyStorePassword) throws Exc
339
339
}
340
340
}
341
341
342
- private boolean verifySignedPackage (File signedPackage ) throws IOException , InterruptedException {
342
+ private boolean verifySignedPackage (File signedPackage ) throws Exception {
343
343
String [] args = {
344
- System .getProperty ("java.home" ) + System .getProperty ("file.separator" ) + ".."
345
- + System .getProperty ("file.separator" ) + "bin"
346
- + System .getProperty ("file.separator" ) + "jarsigner" ,
347
344
"-verify" , signedPackage .getCanonicalPath ()
348
345
};
349
346
350
- Process signingProcess = Runtime .getRuntime ().exec (args );
351
- signingProcess .waitFor ();
347
+ PrintStream defaultPrintStream = System .out ;
352
348
353
- InputStream is = signingProcess .getInputStream ();
354
- InputStreamReader isr = new InputStreamReader (is );
355
- BufferedReader br = new BufferedReader (isr );
356
- String line ;
349
+ ByteArrayOutputStream baos = new ByteArrayOutputStream ();
350
+ PrintStream printStream = new PrintStream (baos );
351
+ System .setOut (printStream );
357
352
358
- while (( line = br . readLine ()) != null ) {
359
- if ( line . contains ( "verified" )) {
360
- return true ;
361
- }
362
- }
353
+ SystemExitControl . forbidSystemExitCall ();
354
+ try {
355
+ JarSigner . main ( args ) ;
356
+ } catch ( SystemExitControl . ExitTrappedException ignored ) { }
357
+ SystemExitControl . enableSystemExitCall ();
363
358
364
- return false ;
359
+ System .setOut (defaultPrintStream );
360
+ String result = baos .toString ();
361
+
362
+ baos .close ();
363
+ printStream .close ();
364
+
365
+ return result .contains ("verified" );
365
366
}
366
367
367
368
private File zipalignPackage (File signedPackage , File projectFolder ) throws IOException , InterruptedException {
0 commit comments