I have a Gradle project with a lot of Kotlin sub-m...
# gradle
t
I have a Gradle project with a lot of Kotlin sub-mobules. I'd like to configure
kotlinOptions
and
kapt
for each of those modules without repeating myself, how can I centralize configuration ? I've found very few official resources on Kotlin project modularization.
v
The idiomatic way is to write a convention plugin, for example as precompiled script plugin but full-fledged plugin would also be ok, either in
buildSrc
or an included build like
build-logic
and then apply that convention plugin to the projects where you want these conventions / settings applied.
t
I just tried the
buildSrc
approach and got odd IDE errors (projects seems to build fine though). I use Android Studio 2020.3.1, any idea how to solve this ?
v
I have no idea about Android stuff. The lower part (
kotlinOptions
) really makes me wonder, as it correctly has
this: KotlinCompile
, so
kotlinOptions
should work fine. Maybe if you do "Invalidate Caches and Restart", maybe some cache got confused. In rare cases it is also necessary to manually nuke the cache directories which does even more than that action.