From f9a2474c1ebbcbc36d4d870c0eee3ea0d7a1f54a Mon Sep 17 00:00:00 2001 From: BoD Date: Sun, 13 Dec 2020 15:12:40 +0100 Subject: [PATCH] Improve dependency notation --- buildSrc/build.gradle.kts | 1 + buildSrc/src/main/kotlin/Utils.kt | 4 +++- library/build.gradle.kts | 24 ++++++++++++------------ samples/sample-jvm/build.gradle.kts | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index d63ae90..f84cc70 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -11,4 +11,5 @@ repositories { dependencies { implementation("ca.rmen:lib-french-revolutionary-calendar:1.8.0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.4.21") } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Utils.kt b/buildSrc/src/main/kotlin/Utils.kt index e3e5c4c..3d05074 100644 --- a/buildSrc/src/main/kotlin/Utils.kt +++ b/buildSrc/src/main/kotlin/Utils.kt @@ -1,5 +1,6 @@ import ca.rmen.lfrc.FrenchRevolutionaryCalendar import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler import java.io.File import java.io.FileInputStream import java.io.FileOutputStream @@ -132,4 +133,5 @@ fun Project.printSplashScreen() { ) } -fun dependency(group: String, artifact: String, version: String) = "$group:$artifact:$version" \ No newline at end of file +fun KotlinDependencyHandler.implementation(group: String, artifact: String, version: String) = + implementation("$group:$artifact:$version") \ No newline at end of file diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 88aebf6..e2dfbb3 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -67,10 +67,10 @@ kotlin { dependencies { implementation(kotlin("stdlib")) - implementation(dependency("io.ktor", "ktor-client-core", Versions.KTOR)) - implementation(dependency("io.ktor", "ktor-client-json", Versions.KTOR)) - implementation(dependency("io.ktor", "ktor-client-serialization", Versions.KTOR)) - implementation(dependency("io.ktor", "ktor-client-logging", Versions.KTOR)) + implementation("io.ktor", "ktor-client-core", Versions.KTOR) + implementation("io.ktor", "ktor-client-json", Versions.KTOR) + implementation("io.ktor", "ktor-client-serialization", Versions.KTOR) + implementation("io.ktor", "ktor-client-logging", Versions.KTOR) } } val commonTest by getting { @@ -82,8 +82,8 @@ kotlin { val jvmMain by getting { dependencies { - implementation(dependency("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8", Versions.COROUTINES)) - implementation(dependency("io.ktor", "ktor-client-okhttp", Versions.KTOR)) + implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8", Versions.COROUTINES) + implementation("io.ktor", "ktor-client-okhttp", Versions.KTOR) } } val jvmTest by getting { @@ -95,9 +95,9 @@ kotlin { val androidMain by getting { dependencies { - implementation(dependency("org.jetbrains.kotlinx", "kotlinx-coroutines-android", Versions.COROUTINES)) - implementation(dependency("io.ktor", "ktor-client-okhttp", Versions.KTOR)) - implementation(dependency("org.slf4j", "slf4j-android", Versions.SLF4J)) + implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-android", Versions.COROUTINES) + implementation("io.ktor", "ktor-client-okhttp", Versions.KTOR) + implementation("org.slf4j", "slf4j-android", Versions.SLF4J) } } val androidTest by getting { @@ -110,7 +110,7 @@ kotlin { // Javascript is commented for now - I don't know how this actually works and how to test it // val jsMain by getting { // dependencies { -// implementation(dependency("io.ktor", "ktor-client-json-js", "$versions.ktor")) +// implementation("io.ktor", "ktor-client-json-js", "$versions.ktor") // } // } // val jsTest by getting { @@ -121,7 +121,7 @@ kotlin { val macosMain by getting { dependencies { - implementation(dependency("io.ktor", "ktor-client-curl", Versions.KTOR)) + implementation("io.ktor", "ktor-client-curl", Versions.KTOR) } } val macosTest by getting { @@ -129,7 +129,7 @@ kotlin { val iosMain by getting { dependencies { - implementation(dependency("io.ktor", "ktor-client-ios", Versions.KTOR)) + implementation("io.ktor", "ktor-client-ios", Versions.KTOR) } } val iosTest by getting { diff --git a/samples/sample-jvm/build.gradle.kts b/samples/sample-jvm/build.gradle.kts index de4f28d..5d061bb 100644 --- a/samples/sample-jvm/build.gradle.kts +++ b/samples/sample-jvm/build.gradle.kts @@ -15,7 +15,7 @@ tasks.withType { dependencies { // Kotlin implementation(kotlin("stdlib-jdk8", Versions.KOTLIN)) - implementation(dependency("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8", Versions.COROUTINES)) + implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8", Versions.COROUTINES) // Library implementation(project(":klibqonto"))