欢迎使用CSDN-markdown编辑器

来源:互联网 发布:java jsonarray 删除 编辑:程序博客网 时间:2024/06/03 17:50

gradle keyPassword System.console

https://stackoverflow.com/questions/19487576/gradle-build-null-console-object

gradle.taskGraph.whenReady { taskGraph ->
if(taskGraph.hasTask(‘:app:assembleRelease’)) {
def storePass = ”
def keyPass = ”
if(System.console() == null) {
new SwingBuilder().edt {
dialog(modal: true, title: ‘Enter password’, alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
vbox { // Put everything below each other
label(text: “Please enter store passphrase:”)
def input1 = passwordField()
label(text: “Please enter key passphrase:”)
def input2 = passwordField()
button(defaultButton: true, text: ‘OK’, actionPerformed: {
storePass = input1.password;
keyPass = input2.password;
dispose();
})
}
}
}
} else {
storePass = System.console().readPassword(“\nPlease enter store passphrase: “)
keyPass = System.console().readPassword(“\nPlease enter key passphrase: “)
}

    if(storePass.size() <= 0 || keyPass.size() <= 0) {        throw new InvalidUserDataException("You must enter the passwords to proceed.")    }    storePass = new String(storePass)    keyPass = new String(keyPass)    android.signingConfigs.release.storePassword = storePass    android.signingConfigs.release.keyPassword = keyPass}

}

原创粉丝点击