Trying to work out how to specify a base gradle KT...
# gradle
m
Trying to work out how to specify a base gradle KTS file (for things like compile/min/target sdk etc) to be applied by each android library module. Is this still not possible? https://github.com/gradle/kotlin-dsl-samples/issues/1287
m
Just don't use the generated accessors. replace
android {}
with
configure<BaseExtension>{}
Ah no I missed that part:
Copy code
In other words they don't share the classpath of the plugins applied to the project build script, hence they cannot see com.android.*
So it does look impossible indeed, sorry. It's more a limitation of gradle than kts though
m
Thanks, yeah, I just found that out:
Unresolved reference: android
when trying to reference
com.android.build.gradle.BaseExtension
m
I could really use some article/talk about how Gradle uses classloaders
This whole part looks pretty complex
m
For me, it has to be simple to implement/understand, otherwise better to stick with copy-paste!
t
I would advice you to put this shared logic inside
buildSrc
module as kotlin script plugin - then you could just apply it to each android subproject. See https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:precompiled_plugins
👍 1