Remote build fails to resolve 'services.gradle.org'

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’ when Gradle tries to download its distribution.

Any help would be appreciated.

Thanks!

  • Can you post your snapcraft.yaml?
  • Does it work when you build locally?

I know that some protocols do not work inside the Launchpad remote-build environment (git:// for example).

there are also proxies involved that you might need to hand through to the actual build system like in:

@mr_cal , local builds complete just fine, that host is unresolved only when building on Launchpad.

name: dogcat
base: core22
...

architectures:
  - build-on: amd64
  - build-on: arm64

apps:
  dogcat:
    command: dogcat.kexe
    plugs:
      - adb-support
      - process-control
    environment:
      PATH: $SNAP/usr/lib/android-sdk/platform-tools:$PATH
      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/android/

parts:
  dogcat:
    plugin: nil
    source: https://github.com/NorseDreki/dogcat
    source-type: git
    source-branch: main
    override-build: |
      echo $CRAFT_ARCH_BUILD_FOR
      if [[ "$CRAFT_ARCH_BUILD_FOR" == "amd64" ]]
      then
        ./gradlew linkReleaseExecutableNativeLinuxX64 -Djava.net.useSystemProxies=true \
        && mv build/bin/nativeLinuxX64/releaseExecutable/dogcat.kexe $SNAPCRAFT_STAGE
      fi
      if [[ "$CRAFT_ARCH_BUILD_FOR" == "arm64" ]]
      then
        ./gradlew linkReleaseExecutableNativeLinuxArm64 -Djava.net.useSystemProxies=true \
        && mv build/bin/nativeLinuxArm64/releaseExecutable/dogcat.kexe $SNAPCRAFT_STAGE
      fi
    override-stage: |
      craftctl default
      mv dogcat.kexe $SNAPCRAFT_PRIME
    build-packages:
      - openjdk-17-jre-headless
      - libncurses-dev
    stage-packages:
      - libncursesw6
      - adb

Trying to favour proxies by passing -Djava.net.useSystemProxies=true to the command which accesses services.gradle.org, but it doesn’t seem to help.

Interesting, it does look like a launchpad-specific connection issue. It’s unfortunate that -Djava.net.useSystemProxies=true isn’t working, as seems like it was successful for other users in Services.gradle.org seems blocked on automated build

Looks like this option works only if the gradle plugin is applied which I cannot do since I’m relying on core22 which doesn’t support that gradle plugin.

I wanted to use Launchpad to build for the Arm64 architecture which I’m not in possesion of, seems I need to find it elsewhere…

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

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
3 Likes

This works well if the server builds the snap, but locally not:

/bin/bash: line 59: https_proxy: unbound variable
++ cut -d/ -f3
++ cut -d: -f1
+ https_proxy_host=
'override-build' in part 'geogebra-discovery' failed with code 1.
Review the scriptlet and make sure it's correct.

Anyway, this is okay for a temporary solution, thanks!

1 Like