Skip to content

Commit cc74e20

Browse files
committed
Try to sign package programmatically
1 parent 2dc2f61 commit cc74e20

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

build.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
${processing.dir}/app/pde.jar;
4646
${processing.dir}/app/lib/ant.jar;
4747
${processing.dir}/app/lib/ant-launcher.jar;
48-
${processing.dir}/app/lib/antlr.jar"
48+
${processing.dir}/app/lib/antlr.jar;
49+
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/lib/tools.jar/"
4950
debug="on">
5051
<src path="src" />
5152
</javac>

src/processing/mode/android/AndroidBuild.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import processing.app.exec.ProcessResult;
3434
import processing.core.PApplet;
3535
import processing.mode.java.JavaBuild;
36+
import sun.security.tools.JarSigner;
3637

3738
import java.io.*;
3839

@@ -273,7 +274,7 @@ public File exportProject() throws IOException, SketchException {
273274
return null;
274275
}
275276

276-
public File exportPackage() throws IOException, SketchException, InterruptedException {
277+
public File exportPackage() throws Exception {
277278
File projectFolder = build("release");
278279
if(projectFolder == null) return null;
279280

@@ -285,7 +286,7 @@ public File exportPackage() throws IOException, SketchException, InterruptedExce
285286
return new File(exportFolder, "/bin/");
286287
}
287288

288-
private File signPackage() throws IOException, InterruptedException {
289+
private File signPackage() throws Exception {
289290
File keyStore = getKeyStore();
290291
if(keyStore == null) return null;
291292

@@ -297,9 +298,6 @@ private File signPackage() throws IOException, InterruptedException {
297298
String password = "generatedpasswordhere";
298299

299300
String[] args = {
300-
System.getProperty("java.home") + System.getProperty("file.separator") + ".."
301-
+ System.getProperty("file.separator") + "bin"
302-
+ System.getProperty("file.separator") + "jarsigner",
303301
"-sigalg", "SHA1withRSA",
304302
"-digestalg", "SHA1",
305303
"-keypass", password,
@@ -309,8 +307,8 @@ private File signPackage() throws IOException, InterruptedException {
309307
sketch.getName()
310308
};
311309

312-
Process signingProcess = Runtime.getRuntime().exec(args);
313-
signingProcess.waitFor();
310+
// TODO remove hardcoded tools.jar path from build.xml
311+
JarSigner.main(args);
314312

315313
if(verifySignedPackage(unsignedPackage)) {
316314
File signedPackage = new File(sketch.getFolder(), "android/bin/" + sketch.getName() + "-release-signed.apk");

src/processing/mode/android/AndroidEditor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ public void run() {
395395
statusError(e);
396396
} catch (InterruptedException e) {
397397
e.printStackTrace();
398+
} catch (Exception e) {
399+
e.printStackTrace();
398400
}
399401
stopIndeterminate();
400402
}

0 commit comments

Comments
 (0)