How do you use convention plugins to setup the sdk of a android application and android library? Ide...
h
How do you use convention plugins to setup the sdk of a android application and android library? Ideally, I want to apply a base android plugin to get the
android
extension with the type of
CommonExtension
d
You’ll want to take this to here - https://gradle-community.slack.com/archives/CJYS1DAP5
g
Look at nowinandroid in Github
h
d
The Gradle slack workspace I linked above would be a great place for this question. There’s an Android channel in there that gets contributions from both Gradle and AGP contributors. To do this, it’s rather simple. In your
build-conventions
source, you’d have your script, e.g.,
myapplication-application-conventions
and
myapplication-library-conventions
as a plug in script. At the top of the convention, you’d apply the plug in. e.g (in library convetion):
Copy code
plugins {
  id("com.android.library")
}

android {
  //build logic for all libraries
}
Then in a library build script (same would hold for your application):
Copy code
plugins {
  id("myapplication-library-conventions")
}

// add anything additional the library may need, such as testNamespace
h
Yeah, implementing the plugins is easy. I was more surprised to see no common android plugin provinding a
CommonExtension
.
d
Isn’t that what
ApplicationExtension
,
DynamicFeatureExtension
,
LibraryExtension
and
TestExtension
are?