Gradle build null console object

后端 未结 10 2248
被撕碎了的回忆
被撕碎了的回忆 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:59

    Ok, the reason why this didn't work was silly, but just in case anyone else comes across it I thought I'd post.

    I was running the task through android studio and didn't realise that the console object would always be null. When running from the command line the "command" object isn't null and it works ok.

    0 讨论(0)
  • 2020-12-02 23:00

    You can execute your script also with:

    -Dorg.gradle.daemon=false

    0 讨论(0)
  • 2020-12-02 23:01
    password System.console() != null ? System.console().readLine("\ password: ") : ""
    
    0 讨论(0)
  • For some reason, running gradle in daemon mode causes a null console object. If you specify the appropriate command line flag,

    ./gradlew assembleRelease --no-daemon

    it'll work.

    0 讨论(0)
提交回复
热议问题