Reputation: 553
This is for downloading gradle itself. I'm trying to cache it inside a corporate network as easily as possible. If gradle is available in a nexus repo upstream, then I can point the distributionUrl for the wrapper to the internal nexus.
Maven is available in maven central which is convenient and I was trying to find a similar solution. https://search.maven.org/search?q=g:org.apache.maven%20a:apache-maven
I did find but I was wondering if there was something more official. https://github.com/hazendaz/gradle https://search.maven.org/search?q=g:com.github.hazendaz.gradle%20a:gradle
Thanks for your time
Upvotes: 3
Views: 2134
Reputation: 1762
The solution offered by M.P. Korstanje did not work for me directly, b/c my version of Nexus does not allow me to proxy raw websites. However, I was able to achieve similar functionality by creating a Hosted "Site" repository, and then uploading the Gradle bin zips to my repo with this script:
#/bin/bash
#
# This helper script will upload any file to 'Gradle Distributions' Nexus repo
#
NEXUS_ADMIN_USER=$1
GRADLE_BIN_ZIP_FILE=$2
if [ -z "$NEXUS_ADMIN_USER" ] \
|| [ -z "$GRADLE_BIN_ZIP_FILE" ]
then
echo "$0 <NEXUS_ADMIN_USER> <GRADLE_BIN_ZIP_FILE>"
exit 1
fi
curl -v \
--user $NEXUS_ADMIN_USER \
--upload-file $GRADLE_BIN_ZIP_FILE \
http://nexus-host:8081/nexus/content/sites/gradle-distributions/$GRADLE_BIN_ZIP_FILE
So now all of the approved Gradle distros are available at a Nexus-managed URL:
http://nexus-host:8081/nexus/content/sites/gradle-distributions/
├── gradle-3.5.1-bin.zip
├── gradle-7.4.1-bin.zip
├── gradle-7.4.2-bin.zip
└── upload_gradle_distro.sh
The last step is to modify gradle/wrapper/gradle-wrapper.properties
:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=http\://nexus-host\:8081/nexus/content/sites/gradle-distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Upvotes: 0
Reputation: 12029
When using Nexus you can create a raw (proxy)
repository for https://services.gradle.org/distributions
. This will proxy all requests.
In this instance the repository is named gradle-distributions
. This allows you to use:
curl https://nexus.example-organisation.com/repository/gradle-distributions/gradle-6.9.1-wrapper.jar.sha256
e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637
Instead of:
curl https://services.gradle.org/distributions/gradle-6.9.1-wrapper.jar.sha256
e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637
So then in gradle-wrapper.properties
you can use:
distributionUrl=https://nexus.example-organisation.com/repository/gradle-distributions/gradle-6.9.1-bin.zip
Upvotes: 4
Reputation: 22952
Unfortunately no. The Gradle Wrapper JAR is not published to a Maven repository such as Nexus.
You can see on this line where the actual download occurs. Digging further in you can see here Gradle uses lower level Java mechanisms to download the wrapper.
All Gradle distributions are available here: https://services.gradle.org/distributions/. If you look at the version information, there is a JSON file that contains what the latest release version is. I'm not entirely familiar with managing Nexus, but if you could somehow create a plugin of some sort to poll that version information, then you could download it if it's not already available/cached in Nexus.
Upvotes: 2