From 71a02e7630adcc981b87d5c9fbf449d09bd40229 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 20 Sep 2020 21:32:05 +0800 Subject: [PATCH] Import yamlkt using 'implementation', improve buildscript --- backend/mirai-console/build.gradle.kts | 5 ++--- buildSrc/src/main/kotlin/dependencyExtensions.kt | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/mirai-console/build.gradle.kts b/backend/mirai-console/build.gradle.kts index 6aad5bba4..3bb13026b 100644 --- a/backend/mirai-console/build.gradle.kts +++ b/backend/mirai-console/build.gradle.kts @@ -65,10 +65,9 @@ dependencies { compileAndTestRuntime(kotlinx("serialization-core", Versions.serialization)) compileAndTestRuntime(kotlin("reflect")) - implementation("org.jetbrains:annotations:19.0.0") - + smartImplementation("net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}") + smartImplementation("org.jetbrains:annotations:19.0.0") smartApi(kotlinx("coroutines-jdk8", Versions.coroutines)) - smartApi("net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}") testApi("net.mamoe:mirai-core-qqandroid:${Versions.core}") testApi(kotlin("stdlib-jdk8")) diff --git a/buildSrc/src/main/kotlin/dependencyExtensions.kt b/buildSrc/src/main/kotlin/dependencyExtensions.kt index d1b817404..76b6fd9b5 100644 --- a/buildSrc/src/main/kotlin/dependencyExtensions.kt +++ b/buildSrc/src/main/kotlin/dependencyExtensions.kt @@ -26,9 +26,22 @@ fun DependencyHandler.compileAndTestRuntime(any: Any) { fun DependencyHandler.smartApi( dependencyNotation: String +): ExternalModuleDependency { + return smart("api", dependencyNotation) +} + +fun DependencyHandler.smartImplementation( + dependencyNotation: String +): ExternalModuleDependency { + return smart("implementation", dependencyNotation) +} + +private fun DependencyHandler.smart( + configuration: String, + dependencyNotation: String ): ExternalModuleDependency { return addDependencyTo( - this, "api", dependencyNotation + this, configuration, dependencyNotation ) { fun exclude(group: String, module: String) { exclude(mapOf(