Gradle build null console object

后端 未结 10 2314
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 22:26

I\'m trying to get my gradle builds to prompt at the console for a password using examples from stack overflow

When I have a statment such as:

def pa         


        
10条回答
  •  一个人的身影
    2020-12-02 22:48

    Simple solution to this is to check the console object for null:

    def password = null
    def console = System.console()
    if (console != null) {
        password = console.readLine("Enter keystore password: ")
    }
    

    Android Studio no longer complaints about the null object.

    To hide typed chars use readPassword() instead of readLine():

    password = new String(console.readPassword("\nEnter key password: "))
    

提交回复
热议问题