This message was deleted.
# dependency-management
s
This message was deleted.
v
o
The reason why it is this way by default is because Gradle cannot assume that
bar
does not contain code that will affect
foo
. You could have a
project(":foo").configure { ... }
anywhere in
bar
or some code it depends on, and Gradle has historically allowed that. Configure on demand is a way to tell Gradle to assume that your build will not do this. In the future, project isolation (which forbids this inter-project interaction) will be the correct way to ensure this property.
party gradlephant 2
k
I do have configuration on demand enabled:
org.gradle.configureondemand=true
v
Could you share a reproducer then?
k
Long story short, I’ve got a KMP project targeting iOS and Android, I’m building both targets on different CI set ups. The problem that I’m running into is the fact that my CI setup for iOS doesn’t have Android SDK set up and that fails configuration of my project, because I have a module that applies a Gradle plugin (rust-android-gradle) requiring Android SDK/NDK and all that…
The exact error that I’m getting is this:
Copy code
Caused by: com.android.builder.errors.EvalIssueException: SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at '.../app/local.properties'.
        at com.android.builder.errors.IssueReporter.reportError(IssueReporter.kt:112)
        at com.android.builder.errors.IssueReporter.reportError$default(IssueReporter.kt:108)
        at com.android.build.gradle.internal.SdkLocator.getSdkLocation(SdkLocator.kt:239)
        at com.android.build.gradle.internal.SdkLocator.getSdkDirectory(SdkLocator.kt:197)
        at com.android.build.gradle.internal.cxx.configure.NdkLocator.findNdkPath(NdkLocator.kt:454)
        at com.android.build.gradle.internal.ndk.NdkHandler.getNdkStatus(NdkHandler.kt:85)
        at com.android.build.gradle.internal.ndk.NdkHandler.getNdkPlatform(NdkHandler.kt:98)
        at com.android.build.gradle.internal.ndk.NdkHandler.getNdkPlatform(NdkHandler.kt:104)
        at com.android.build.gradle.BaseExtension$ndkDirectory$1.transform(BaseExtension.kt:384)
        at com.android.build.gradle.BaseExtension$ndkDirectory$1.transform(BaseExtension.kt:378)
        at org.gradle.api.internal.provider.ValueSupplier$Present.transform(ValueSupplier.java:541)
        at org.gradle.api.internal.provider.TransformBackedProvider.mapValue(TransformBackedProvider.java:91)
        at org.gradle.api.internal.provider.TransformBackedProvider.calculateOwnValue(TransformBackedProvider.java:83)
        at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateOwnPresentValue(AbstractMinimalProvider.java:73)
        at org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:93)
        at com.android.build.gradle.BaseExtension.getNdkDirectory(BaseExtension.kt:385)
        at com.nishtahir.RustAndroidPlugin$apply$$inlined$with$lambda$1$1.execute(RustAndroidPlugin.kt:528)
        at com.nishtahir.RustAndroidPlugin$apply$$inlined$with$lambda$1$1.execute(RustAndroidPlugin.kt:157)
I want to avoid unnecessarily setting up Android environment for the iOS CI
The
rust-android-gradle
plugin triggers these checks when it’s being applied by applying AGP plugins:
Copy code
open class RustAndroidPlugin : Plugin<Project> {
    internal lateinit var cargoExtension: CargoExtension

    override fun apply(project: Project) {
        with(project) {
            cargoExtension = extensions.create("cargo", CargoExtension::class.java)

            afterEvaluate {
                plugins.all {
                    when (it) {
                        is AppPlugin -> configurePlugin<AppExtension>(this)
                        is LibraryPlugin -> configurePlugin<LibraryExtension>(this)
                    }
                }
            }

        }
    }
In my module, that I only use for
androidMain
targets I apply the plugin like so:
Copy code
plugins {
  ...
  alias(libs.plugins.rust.android) // this applies RustAndroidPlugin
}

// configure plugin
cargo {
  ...
}
I don’t have this type of problem with other android modules in the project, just this plugin. My Gradle-fu is limited but my guess is that the plugin is implemented in a way that doesn’t do configuration avoidance properly (or something), or I’m just doing something wrong
Since the module using
rust-android-gradle
is part of the entire Gradle project, I’m guessing it will get configured no matter what, right?