Skip to content

Commit 1e7ce19

Browse files
author
Mihail Slavchev
committed
use string array to pass the arguments
1 parent ce7c6c6 commit 1e7ce19

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

build/project-template-gradle/build.gradle

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,38 @@ task buildMetadata (type: JavaExec) {
356356
def androidHome = new File(System.properties['user.home'], ".android")
357357
def keyStoreFile = new File(androidHome, "debug.keystore")
358358

359-
def cmd = "jarsigner -sigalg SHA1withRSA -digestalg SHA1 " + (project.ext.selectedBuildType.equals("release")
360-
? ("-storepass " + project.password + " -keypass " + project.ksPassword + " -keystore \"" + project.ksPath + "\" \"" + currentApk + "\" " + project.alias)
361-
: ("-storepass android -keypass android -keystore \"" + keyStoreFile.getAbsolutePath() + "\" \"" + currentApk + "\" androiddebugkey"))
359+
def storePass
360+
def keyPass
361+
def keyStorePath
362+
def alias
363+
364+
currentApk = "\"" + currentApk + "\""
365+
366+
if (project.ext.selectedBuildType.equals("release")) {
367+
storePass = project.password
368+
keyPass = project.ksPassword
369+
keyStorePath = "\"" + project.ksPath + "\""
370+
alias = project.alias
371+
} else {
372+
storePass = "android"
373+
keyPass = "android"
374+
keyStorePath = "\"" + keyStoreFile.getAbsolutePath() + "\""
375+
alias = "androiddebugkey"
376+
}
377+
378+
def cmdParams = new ArrayList<String>(["jarsigner", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-storepass", storePass, "-keypass", keyPass, "-keystore", keyStorePath, currentApk, alias])
379+
380+
if (isWinOs) {
381+
cmdParams.add(0, "/c")
382+
cmdParams.add(0, "cmd")
383+
}
362384

363385
exec {
364386
if (isWinOs) {
365-
commandLine "cmd", "/c", cmd
387+
commandLine cmdParams.toArray()
366388
}
367389
else {
368-
commandLine cmd
390+
commandLine cmdParams.toArray()
369391
}
370392
}
371393
}

0 commit comments

Comments
 (0)