Avoid Build Repository Credentials in build.gradle

Hi, I created a gradle plugin and using it in my product build.gradle file. The plugin is consumed from Maven repository which requires authentication.

So I provided the following to make it work

buildscript {
  maven {
           credentials {  username "xyz@x.com" password "abc" }
           url 'corpMvnURL'
      } 
}

apply plugin:  "myplugin"

Now, the problem is including credentials in buildScript which is exposed to several audience. Is there any other way to avoid hardcoding of password in build.gradle file.

You can put properties in GRADLE_USER_HOME/gradle.properties or you can pass in properties from command line

eg gradle build -Puser=xxx -Ppassword=yyy

You can then access them in a gradle script via hasProperty(name), getProperty(name) and findProperty(name) methods (see Project javadocs)

Eg

repositories  {
  maven {
    credentials {  
      username getProperty('user') 
      password getProperty('password') 
    } 
}

I have the same question but want to avoid storing the password in any file. Is there any way to get gradle to prompt me for the password? Using gradle 4.10

Current code is:

buildscript {
repositories {
maven {
credentials {
username project.username
password project.password
}