Skip to content

Instantly share code, notes, and snippets.

@alwarren
Last active January 20, 2023 15:24
Show Gist options
  • Save alwarren/d95636c29197828d6f39446bab55effa to your computer and use it in GitHub Desktop.
Save alwarren/d95636c29197828d6f39446bab55effa to your computer and use it in GitHub Desktop.
Kotlin DSL (IntelliJ IDEA 2022)
import org.gradle.kotlin.dsl.`kotlin-dsl`
// Path project_root/buildSrc
plugins{
`kotlin-dsl`
}
repositories{
mavenCentral()
}
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Path project root
plugins {
kotlin("jvm") version "1.7.21"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(Dependencies.Kotlin.stdlib)
implementation(Dependencies.Kotlin.coroutines)
implementation(Dependencies.Gson.base)
implementation(Dependencies.Retrofit.base)
implementation(Dependencies.Retrofit.gson)
implementation(Dependencies.Retrofit.jaxb)
implementation(Dependencies.Retrofit.scalars)
testImplementation(kotlin("test"))
testImplementation(Dependencies.Jupiter.api)
testImplementation(Dependencies.Jupiter.params)
testImplementation(Dependencies.Kluent.base)
testImplementation(Dependencies.Mockk.base)
}
// Path project_root/buildSrc/src/main/kotlin
object Dependencies {
object Kotlin {
val stdlib: String = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}"
val coroutines: String = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}"
}
object Retrofit {
val base: String = "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
val gson: String = "com.squareup.retrofit2:converter-gson:${Versions.retrofit}"
val jaxb: String = "com.squareup.retrofit2:converter-jaxb:${Versions.retrofit}"
val scalars: String = "com.squareup.retrofit2:converter-scalars:${Versions.retrofit}"
}
object Gson {
val base: String = "com.google.code.gson:gson:${Versions.gson}"
}
object Jupiter {
val api = "org.junit.jupiter:junit-jupiter-api:${Versions.jupiter}"
val params = "org.junit.jupiter:junit-jupiter-params:${Versions.jupiter}"
}
object Kluent {
val base = "org.amshove.kluent:kluent:${Versions.kluent}"
}
object Mockk {
val base = "io.mockk:mockk:${Versions.mockk}"
}
}
// Path project_root/buildSrc/src/main/kotlin
object Versions {
const val kotlin = "1.8.0"
const val coroutines: String = "1.6.4"
const val retrofit: String = "2.9.0"
const val gson: String = "2.10.1"
const val jupiter: String = "5.9.2"
const val kluent: String = "1.72"
const val mockk: String = "1.13.3"
}
@alwarren
Copy link
Author

kotlin_dsl_intellij

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment