@@ -339,29 +339,30 @@ private File signPackage(File projectFolder, String keyStorePassword) throws Exc
339339 }
340340 }
341341
342- private boolean verifySignedPackage (File signedPackage ) throws IOException , InterruptedException {
342+ private boolean verifySignedPackage (File signedPackage ) throws Exception {
343343 String [] args = {
344- System .getProperty ("java.home" ) + System .getProperty ("file.separator" ) + ".."
345- + System .getProperty ("file.separator" ) + "bin"
346- + System .getProperty ("file.separator" ) + "jarsigner" ,
347344 "-verify" , signedPackage .getCanonicalPath ()
348345 };
349346
350- Process signingProcess = Runtime .getRuntime ().exec (args );
351- signingProcess .waitFor ();
347+ PrintStream defaultPrintStream = System .out ;
352348
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 );
357352
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 ();
363358
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" );
365366 }
366367
367368 private File zipalignPackage (File signedPackage , File projectFolder ) throws IOException , InterruptedException {
0 commit comments