简体   繁体   English

如何将命令行参数作为密码传递给Gradle项目?

[英]How to pass command line argument as a password to gradle project?

Hi i want to pass username and password as a command line argument and i am able to do that but my problem is when i entered password it get displayed on command line. 嗨,我想通过用户名和密码作为命令行参数,我能够做到这一点,但是我的问题是当我输入密码时,它会显示在命令行中。 I want to display in ***** format. 我想以*****格式显示。

Depending on your console, the following code will get the Console object and will take input while masking the console echo. 根据您的控制台,以下代码将获取Console对象,并在屏蔽控制台回显时接受输入。

Console console = System.console();
char password[] = console.readPassword("Enter password: ");
console.printf("You entered: %s%n", new String(password));

Note that if you are using an IDE with a built-in console (IE Eclipse), this may not work. 请注意,如果您将IDE与内置控制台(IE Eclipse)配合使用,则可能无法使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM