Gradle 构建空控制台对象 [英] Gradle build null console object
问题描述
我正在尝试使用堆栈溢出示例让我的 gradle 构建在控制台提示输入密码
I'm trying to get my gradle builds to prompt at the console for a password using examples from stack overflow
当我有一个声明例如:
def password = System.console().readLine("Enter keystore password ")
运行时出现错误
Cannot invoke method readLine() on null object
似乎控制台显示为 null
.我读过的内容需要 java 6,如果我转到命令提示符并键入 java -version
我正在运行 Java(TM) SE 运行时环境(构建 1.6.0_27-b07).
It seems console is coming out as null
. What I've read this requires java 6 which if I go to a command prompt and type java -version
I'm running Java(TM) SE Runtime Environment (build 1.6.0_27-b07).
此问题正在 Gradle 的 Github 存储库中进行跟踪:Can't use System.console() withGradle 守护进程.
This issue is being tracked in Gradle's Github repo: Can't use System.console() with the Gradle Daemon.
推荐答案
好吧,这行不通的原因很愚蠢,但以防万一其他人遇到它,我想我会发帖.
Ok, the reason why this didn't work was silly, but just in case anyone else comes across it I thought I'd post.
我正在通过 android studio 运行任务,并没有意识到控制台对象始终为空.当从命令行运行时,command"对象不为空,它工作正常.
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.
这篇关于Gradle 构建空控制台对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!