Skip to content

Support configuring the Gradle distribution URL (mirror) #13

Description

@chengjilai

Context

The kotlin command builds Android apps by connecting to Gradle via the Tooling API without specifying a distribution (see amper-android-runner/.../Runner.kt: GradleConnector.newConnector().forProjectDirectory(...).connect()). Gradle therefore downloads its hardcoded default:

https://services.gradle.org/distributions/gradle-VERSION-bin.zip

From mainland China this is effectively unreachable: it redirects to GitHub release assets, which are throttled/blocked. The first Android build fails with: GradleConnectionException: Could not run build action using connection to Gradle distribution ...

What is needed

A supported way to point the toolchain at a Gradle distribution mirror, e.g.:

  • an environment variable (KOTLIN_TOOLCHAIN_GRADLE_DISTRIBUTION_URL or similar), and/or
  • a settings entry in project.yaml / module.yaml.

The toolchain is already aware of the JetBrains redirector for this exact purpose: the test fixtures use cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-...-bin.zip (e.g. sources/dependency-resolution/testData/.../gradle-wrapper.properties) - it is just not exposed in the CLI.

Without this, users must manually pre-seed ~/.gradle/wrapper/dists/ from a mirror, which is fragile and undocumented.

Expected behavior

kotlin build should be able to fetch the Gradle distribution from a configured mirror (JetBrains redirector, Tencent/Aliyun, or a user-provided URL), like Maven repositories already can via module.yaml repositories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions