build.gradle.kts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright 2019-2022 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/dev/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.optIn("kotlin.Experimental")
  21. languageSettings.optIn("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("gradle.plugin.com.google.gradle:osdetector-gradle-plugin:1.7.0")
  51. api(gradleApi())
  52. }