Slackbot
08/16/2023, 2:31 PMChris Sawczuk
08/16/2023, 2:32 PMorg.gradle.api.GradleException: Error resolving plugin [id: 'org.jetbrains.kotlin.android', version: '1.8.21', apply: false]
My understanding is if you want to have a convention that configures android aspects of a project (or kotlin ones in kotlin-jvm modules), you need to import the plugins (?) as dependencies on your buildSrc
module, so that you can expose the APIs used by the actual module build.gradle.kts files in your convention file.Vampire
08/16/2023, 2:33 PMid("org.jetbrains.kotlin.android") version "1.8.21" apply false
?Chris Sawczuk
08/16/2023, 2:34 PMandroid {
testOptions {
unitTests.all { isIncludeResources = true }
}
}
For example, in a android-conventions.gradle.kts
file.
android won't resolve unless the android gradle plugin is added as a dependency to the buildSrc module.
Is this correct or am I way off base?Chris Sawczuk
08/16/2023, 2:34 PMbuild.gradle.kts
fileChris Sawczuk
08/16/2023, 2:34 PM...
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.kotlin.jvm) apply false
}
...
Vampire
08/16/2023, 2:35 PMmy topleveltoplevel of what?filebuild.gradle.kts
Vampire
08/16/2023, 2:35 PMChris Sawczuk
08/16/2023, 2:35 PMproject/
buildSrc/
moduleA/
moduleB/
build.gradle.kts <-- here
Vampire
08/16/2023, 2:36 PMimplementation
dependency of your convention plugin in buildSrc/build.gradle.kts
. You should remove those unless you have a concrete reason to add them which usually are just edge cases.Chris Sawczuk
08/16/2023, 2:37 PMVampire
08/16/2023, 2:37 PMandroid
does not resolve in your android-conventions.gradle.kts
is because you only get type-safe accessors for plugins you applied in that same script in its plugins { ... }
blockVampire
08/16/2023, 2:38 PMso adding them as a dependency to the buildSrc module is the same as applying them as a plugin?No, and what you showed also does not apply them, mind the "apply false".
Vampire
08/16/2023, 2:38 PMalias(libs.plugins.kotlin.jvm) apply false
does not apply anything, it just adds the plugin to the classpathVampire
08/16/2023, 2:38 PMimplementation
dependency of your convention plugin has the same effect, if you actually apply that convention pluginVampire
08/16/2023, 2:40 PMalias(...) apply false
is probably just a bad exampleChris Sawczuk
08/16/2023, 2:40 PMVampire
08/16/2023, 2:42 PMChris Sawczuk
08/16/2023, 2:42 PMChris Sawczuk
08/16/2023, 2:43 PMtoplevel build.gradle.kts file
? Root project build.gradle.kts? I guess that's what gradle would refer to it as 🤔Vampire
08/16/2023, 2:49 PMVampire
08/16/2023, 2:50 PMChris Sawczuk
08/16/2023, 2:50 PM