I want to make some extension methods in buildSrc
to use them in other modules' build.gradle.kts
-files
Particularly I need to extend com.android.build.gradle.LibraryExtension
. For that, I seem to need com.android.library
in buildSrc
's classpath. Trying to achieve that with
plugins {
id("com.android.library") apply false
}
gives me Plugin [id: 'com.android.library', apply: false] was not found in any of the following sources:
error.
What is the correct setup for this purpose?
Full content of build.gradle.kts
from buildSrc
below:
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.6.3")
}
}
plugins {
`kotlin-dsl`
id("com.android.library") apply false
}
Just ignore everything I previously posted. Here is how I was able to use LibraryExtension
. However, ymmv, this seems heavy handed.
repositories {
jcenter()
google()
}
// ...snip...
dependencies {
implementation("com.android.tools.build:gradle:3.6.3")
}
If all you want is access to the class, you want it as a dependency, not a plugin. I'm still not sure how to make this work as a plugin in buildSrc, so hopefully this gets you what you need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.