Using An External And Authentication Required Maven Repository With Gradle
If you need to access an external artifact repository that requires authentication, I’m sure you would not like to keep the repository credentials in the build configuration under version control. However, you might need to access the repository from your dev or CI environments. So if you wonder what the solution is, continue reading.
You have two options:
You can leave the credentials as a variable in the Gradle configuration and either you can pass them from gradle.properties
file like the following:
And that’s how thegradle.properties
file looks like:
Or pass the variables as arguments from the CLI:
$ gradle build \
-PmavenUsername=myuser \
-PmavenPassword=mySecretPassword
As a second solution;
You can use Gradle Maven Settings Plugin to be able to use the repository credentials from the maven configuration…