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

Boost Your Business With Cloud Computing

Writing a Blockchain in Node.js

Quick Answer: What Version Of Windows Do I Have On My Tablet

Imagine taking the time to list all of your ancestors’ ethnicities to a near stranger, forcing

Note in JWT Token in Laravel

API Documentation & Application Monitoring in Spring Boot with Swagger, Prometheus & Grafana

On a scale from 1 to 100, how painful has your digital transformation been so far?

Bring dynamic cards to Dialogflow chat bot on Skype.

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-EN] SSLHandshakeException: Handshake failed

Kotlin: A New Programming Language

Librarylife #6

File System Of Android