Kotlin DSL migration on an existing groovy Android MultiModule Project

  1. Create a module named : “buildSrc” inside the root project.
  2. remove “buildsrc” from settings.gradle
  3. Rename existing build.gradle and settings.gradle files to build.gradle.kts and settings.gradle.kts
  4. adopt the kotlin code style on every *.kts file(groovy will fail, needs to be changed.)
commondep() refers the kotlin fun inside our buildSrc module. so all code remains clean.
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.kotlin
import org.gradle.kotlin.dsl.project

fun Project.commonDep() {
dependencies {
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.7.0")
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.7.0")
"implementation"("io.reactivex.rxjava2:rxjava:2.2.21")
"implementation"("com.google.dagger:dagger:2.37")
"kapt"("com.google.dagger:dagger-compiler:2.37")
}
}

fun Project.dataModuleDep() {
dependencies {
"implementation"(project(":domain"))
}
}

fun Project.networkModuleDep() {
dependencies {
"implementation"(project(":domain"))
"implementation"("com.squareup.retrofit2:retrofit:2.9.0")
"implementation"("com.squareup.retrofit2:converter-gson:2.9.0")
}
}


fun Project.androidUIDep() {
apply(plugin = "com.android.application")
apply(plugin = "kotlin-android")
// configure<AppExtension>("android") {

//}
dependencies {
"implementation"(project(":data"))
"implementation"(project(":domain"))
"implementation"(project(":network"))

"implementation"("com.google.dagger:dagger:2.37")
"implementation"("androidx.navigation:navigation-fragment-ktx:2.3.0")
"implementation"("androidx.navigation:navigation-ui-ktx:2.3.0")
"implementation"("androidx.fragment:fragment-ktx:1.3.6")
"implementation"("androidx.legacy:legacy-support-v4:1.0.0")
"implementation"("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
"implementation"("androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0")
"kapt"("com.google.dagger:dagger-compiler:2.37")
"implementation"("io.reactivex.rxjava2:rxjava:2.2.21")
"implementation"("io.reactivex.rxjava2:rxandroid:2.1.1")
// "implementation"("org.openjfx:javafx:11")
// "implementation"("org.openjfx:javafx-controls:11")

"implementation"("org.jetbrains.kotlin:kotlin-stdlib:1.5.10")

"implementation"("androidx.appcompat:appcompat:1.2.0")
"implementation"("androidx.constraintlayout:constraintlayout:1.1.3")
"testImplementation"("junit:junit:4.+")
"androidTestImplementation"("androidx.test.ext:junit:1.1.1")
"androidTestImplementation"("androidx.test.espresso:espresso-core:3.1.0")
}
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Multiple Git Accounts on same apple machine

CyberTeam India Internship CTF

Adding Images to Github ReadMe

Snapshot of Image on readme file

How to Resolve AWS ElastiCache and Redis CLI Error Connection Reset by Peer

How I launched an iOS App with a teenager

Metauce $MINES Farming on Netswap

Squarespace — ‘Lusaka’ Template CSS Tips #2

You probably don’t want that concurrency in Go

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Berkin Tatlısu

Berkin Tatlısu

Developer

More from Medium

[Android] Did you still using notifyDataSetChanged()?

Upload a document using multipart form using Kotlin rest template

CS371p Spring 2022: Pranav Chunduru

Application FrameWorks.