This is how to read credentials from a .netrc formatted file, which is encrypted using gpg and use these credentials as login data for gradle remote repositories.
First you need to have gpg keys created.
Then create a ~/.netrc
as shown below and encrypt it with gpg -r <your email> -e ~/.netrc
, which will create a .netrc.gpg
. Remove the unencypted .netrc
afterwards.
Now create a ~/.gradle/init.gradle
as shown below.
When gpg is locked, your next gradle build will cause gpg to show a window to enter you gpg key's password.
You can control how long the password should be cached with your ~/.gnupg/gpg-agent.conf using --default-cache-ttl
and --max-cache-ttl
properties.
This was tested on Windows with a default Git installation. gpg is already included in the Git installation.