Build fails to resolve ‘services.gradle.org’

Asked by Alex

Hey folks,

I’m aware there is the ‘gradle’ plugin, but it’s not available with ‘base22’, so I’m invoking ./gradlew directly and build fails with ‘java.net.UnknownHostException: services.gradle.org 1’ when Gradle tries to download its distribution.

I've originally posted this on the Snapcraft forum, but couldn't get a resolution: https://forum.snapcraft.io/t/remote-build-fails-to-resolve-services-gradle-org/39353.

Any help would be appreciated.

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Solved by:
Alex
Solved:
Last query:
Last reply:
Revision history for this message
Alex (norse-dreki) said :
#1

I've also tried to workaround downloading Gradle from `services.gradle.org` by manually downloading it from Github distributions, but Gradle further wants to access build plugins and fails:

```
:: + gradle linkReleaseExecutableNativeLinuxArm64 -Djava.net.useSystemProxies=true
::
:: Welcome to Gradle 8.6!
::
:: Here are the highlights of this release:
:: - Configurable encryption key for configuration cache
:: - Build init improvements
:: - Build authoring improvements
::
:: For more details see https://docs.gradle.org/8.6/release-notes.html
::
:: Starting a Gradle Daemon (subsequent builds will be faster)
::
:: FAILURE: Build failed with an exception.
::
:: * Where:
:: Build file '/build/snapcraft-dogcat-5f5148f9023a7addb04839f123e44a80/parts/dogcat/build/build.gradle.kts' line: 1
::
:: * What went wrong:
:: Plugin [id: 'org.jetbrains.kotlin.multiplatform', version: '1.9.22'] was not found in any of the following sources:
::
:: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
:: - Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.9.22')
:: Searched in the following repositories:
:: MavenRepo
:: Gradle Central Plugin Repository
```

Local and GitHub Actions builds work just fine, I'd suspect network restrictions on Launchpad's side.

Revision history for this message
Alex (norse-dreki) said :
#2
Revision history for this message
Clinton Fung (clinton-fung) said :
#3

Builders aren't directly connected to the Internet and access external services through a forward proxy designated for this purpose. Gradle does not respect the standard `https_proxy` environment variable. You need to add -D parameters to your Gradle incantation to make it use the proxy..

Revision history for this message
Alex (norse-dreki) said (last edit ):
#4

Thanks Clinton,

I was able to put right incantations in place and make Gradle pick up that proxy.

Leaving my solution if anyone ever gets stuck on this:

```
https_proxy_host=$(echo $https_proxy | cut -d'/' -f3 | cut -d':' -f1)
https_proxy_port=$(echo $https_proxy | cut -d'/' -f3 | cut -d':' -f2)
gradle_opts="-Dhttp.proxyHost=$https_proxy_host -Dhttp.proxyPort=$https_proxy_port -Dhttps.proxyHost=$https_proxy_host -Dhttps.proxyPort=$https_proxy_port"

gradle $gradle_opts assemble
```