https://kotlinlang.org logo
m

Mohamed Ibrahim

08/31/2020, 10:30 AM
should I use
buildSrc
or convert all
.gradle
files to Kotlin dsl, preparing to refactor app to Modules?
j

Joost Klitsie

08/31/2020, 10:54 AM
what do you wish to achieve?
m

Mohamed Ibrahim

08/31/2020, 11:09 AM
preparing to refactor app to Modules?
v

Vincent Williams

09/01/2020, 4:06 AM
Im not sure either of your suggestions relate to modules. You dont need kotlin dsl or buildSrc for multi-module
1
m

Mohamed Ibrahim

09/01/2020, 6:21 AM
the idea is to organize dependencies and versions across all modules
j

Joost Klitsie

09/01/2020, 7:09 AM
Okay so buildSrc is a place to put scripts which have access to the gradle API and can be referenced from build.gradle scripts.
you can put in JVM languages, such as Java, Groovy or Kotlin in the buildSrc
So if you have many different modules, using the buildSrc is a good way to go, as you can put that in the root project and then reference it from your modules' build.gradle files
if you do not have a whole lot of modules, then I would advise to use Kotlin everywhere
as I read here a topic by a guy that had 140 modules and noticed that script initialization is a bit slow for build.gradle.kts scipts (like 1s, but times 140 it is a lot)
so you can use the kotlin-dsl plugin in the buildSrc to write kotlin files
There is also people saying you shouldn't use buildSrc as it makes initial builds slower https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds-instead-3c38ac7a2ab3
but in my experience the ease of buildSrc makes it a good choice
m

Mohamed Ibrahim

09/01/2020, 8:28 AM
Thank you, I’ll go with
buildSrc
for now
7 Views