Configure Gradle wrapper distribution URL based on environment variable/user property/whatever else

We have a setup where we work in two separate development networks. We use Artifactory to cache the Gradle distributions. We have separate Artifactory servers, one for each network, which each have different URLs. We have projects that are supposed to work in both networks. We’d like to use the wrapper, but in order to do this, it has to be able to use a different URL, depending on the network.

Is there a way to configure the distributionUrl based on environment variables, user properties, or anything else of the sort?

As far as I know there is nothing built-in for that. You probably need an own wrapper script that wraps the wrapper and before prepares the properties file like you need it.

Ok, so basically to not check in the gradle-wrapper.properties file and re-create it with each invocation.

For example, exactly