I am supporting an open source project that is con...
# community-support
d
I am supporting an open source project that is contributed to by enterprise users who can't download the gradle wrapper through the public URL, but must use a custom
distributionUrl
. I'm wondering if its possible for these users to override the
distributionUrl
without setting it in the
gradle-wrapper.properties
file since they would break the public build if they accidentally checked in their enterprise URL.
v
Would it be workable for them to just ensure the wrapper is already present? Maybe put there by a separate "bootstrapping" build that is only there to get the distribution from the other URL?
j
you could also ask your developers to add a line in
.git/info/exclude
for this project, or provide them a
pre-commit
git hook script to install in
.git/hooks
, though this is more about git than gradle (you could also automate or enforce this with gradle eventually)
v
An exclude is useless. You cannot exclude an already versioned file.
d
If the wrapper already exists, then running
./gradlew
shouldn't try and reach out to the public distribution url, is that correct?
v
Iirc, yes. That's why I suggested to just make sure it is present if possible
👍 1
d
Thanks I'll give it a try
j
then running ./gradlew shouldn't try and reach out to the public distribution url, is that correct?
as long as a distribution with the exact same download URI was already downloaded apparently, having the same version is not enough so your team may still run into issues if they never used a wrapper to download this version of Gradle from the public
<https://services.gradle.org/distributions/gradle->...
E.g. a wrapper-downloaded Gradle 8.8 will end up in
~/.gradle/wrapper/dists/gradle-8.8-bin/dl7vupf4psengwqhwktix4v1/gradle-8.8/
, where
dl7...
is a hash of the download URI. As @Vampire pointed out you can't use
.gitignore
or
.git/info/exclude
to ignore modifications to a file that was checked out, and using
git update-index
doesn't sound like a good idea in this context. You could eventually hack something with gitattributes and a filter, but IMO the best way to deal with this if pre-downloading the public distribution is not possible would be to tell your team not to use the wrapper for this project and use instead a local installation of your private distribution of Gradle.
til 1
v
Oh, the hash is of the download url? o_O
That's unlucky then, then a bootstrap build would not help. But you could still place the distribution there manually, or use a bootstrap build and rename the directory or something like that.
j
yes, or copying the whole tree of your private distribution to the hash of the public URI would probably work here
v
That's what I meant with "rename". Of course "copy" might be more appropriate here as they probably need both, yeah. 🙂
d
Thanks, this makes sense... it really would be nice if you could run the wrapper and pass in the distributionUrl as a Java property or environment variable (the latter is probably better)
v
It wouldn't help if you could
As we just learned, the path to the provisioned distribution contains the url as MD5 hash, which also makes sense
👍 1
Typically you use a custom distribution when you use a custom URL
So you would need to give the distribution url on each invocation and that would be quite cumbersome
If that would be a viable solution, you could probably also instead use the
gradle
executable in the provisioned distribution instead of
gradlew
and basically have the same effect.
d
Darn chicken and egg problems