build.gradle.kts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2019-2021 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/master/LICENSE
  8. */
  9. plugins {
  10. `kotlin-dsl`
  11. }
  12. repositories {
  13. mavenLocal()
  14. google()
  15. mavenCentral()
  16. gradlePluginPortal()
  17. }
  18. kotlin {
  19. sourceSets.all {
  20. languageSettings.useExperimentalAnnotation("kotlin.Experimental")
  21. languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
  22. }
  23. }
  24. private val versionsText = project.projectDir.resolve("src/main/kotlin/Versions.kt").readText()
  25. fun version(name: String): String {
  26. return versionsText.lineSequence()
  27. .map { it.trim() }
  28. .single { it.startsWith("const val $name") }
  29. .substringAfter('"', "")
  30. .substringBefore('"', "")
  31. .also {
  32. check(it.isNotBlank())
  33. logger.debug("$name=$it")
  34. }
  35. }
  36. dependencies {
  37. val asmVersion = version("asm")
  38. fun asm(module: String) = "org.ow2.asm:asm-$module:$asmVersion"
  39. fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
  40. fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
  41. // compileOnly(kotlin("gradle-plugin-api", "1.3.72")) // Gradle's Kotlin is 1.3.72
  42. api("com.github.jengelman.gradle.plugins", "shadow", version("shadow"))
  43. api("org.jetbrains.kotlin", "kotlin-gradle-plugin", version("kotlinCompiler"))
  44. api("org.jetbrains.kotlin", "kotlin-compiler-embeddable", version("kotlinCompiler"))
  45. api(ktor("client-okhttp", "1.4.3"))
  46. api("com.android.tools.build", "gradle", version("androidGradlePlugin"))
  47. api(asm("tree"))
  48. api(asm("util"))
  49. api(asm("commons"))
  50. api(gradleApi())
  51. }