Gradle wrapper download custom distributions with password

I want to use a Gradle Custom Distributions which will have init.d with some gradle script. This Custom Dist will be published to a server which should require username/password to download. As I don’t want to check-in passwords in project’s files, the only viable option seems to be using
~/.gradle/gradle.properties with something like this:

systemProp.gradle.wrapperUser=username
systemProp.gradle.wrapperPassword=password

Which means these values cannot be changed if I have two or more custom distribution URLs which require basic auth. Also, the same auth header will be passed to all wrapper URLs even if they don’t require basic all (like gradle’s default distribution URL.)

What are the workarounds to alleviate this problem? Does Gradle (plan to) support directory tree level setings for example all projects in ~/projects/myorg-1 get different config than projects in ~/projects/myorg-2 ?

Maybe you can use a combination of GRADLE_OPTS and direnv.

export GRADLE_USER=foo
export GRADLE_PASSWORD=bar
export GRADLE_OPTS="-Dgradle.wrapperUser=$GRADLE_USER -Dgradle.wrapperPassword=$GRADLE_PASSWORD"

However please note that you need to configure this seperately for your IDE.