build.gradle.kts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. @file:Suppress("UnusedImport")
  10. plugins {
  11. kotlin("jvm")
  12. id("java-gradle-plugin")
  13. id("com.gradle.plugin-publish")
  14. id("java")
  15. //signing
  16. `maven-publish`
  17. id("com.jfrog.bintray")
  18. id("com.github.johnrengelman.shadow")
  19. }
  20. dependencies {
  21. implementation(project(":mirai-console-compiler-annotations"))
  22. compileOnly(gradleApi())
  23. compileOnly(gradleKotlinDsl())
  24. compileOnly(kotlin("gradle-plugin-api").toString()) {
  25. exclude("org.jetbrains.kotlin", "kotlin-stdlib")
  26. }
  27. compileOnly(kotlin("gradle-plugin").toString()) {
  28. exclude("org.jetbrains.kotlin", "kotlin-stdlib")
  29. }
  30. compileOnly(kotlin("stdlib"))
  31. api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
  32. api(`jetbrains-annotations`)
  33. api("com.jfrog.bintray.gradle:gradle-bintray-plugin:${Versions.bintray}")
  34. }
  35. version = Versions.console
  36. description = "Gradle plugin for Mirai Console"
  37. kotlin {
  38. explicitApi()
  39. }
  40. pluginBundle {
  41. website = "https://github.com/mamoe/mirai-console"
  42. vcsUrl = "https://github.com/mamoe/mirai-console"
  43. tags = listOf("framework", "kotlin", "mirai")
  44. }
  45. gradlePlugin {
  46. plugins {
  47. create("miraiConsole") {
  48. id = "net.mamoe.mirai-console"
  49. displayName = "Mirai Console"
  50. description = project.description
  51. implementationClass = "net.mamoe.mirai.console.gradle.MiraiConsoleGradlePlugin"
  52. }
  53. }
  54. }
  55. kotlin.target.compilations.all {
  56. kotlinOptions {
  57. apiVersion = "1.3"
  58. languageVersion = "1.3"
  59. }
  60. }
  61. tasks {
  62. val compileKotlin by getting {}
  63. val fillBuildConstants by registering {
  64. group = "mirai"
  65. doLast {
  66. (compileKotlin as org.jetbrains.kotlin.gradle.tasks.KotlinCompile).source.filter { it.name == "VersionConstants.kt" }.single()
  67. .let { file ->
  68. file.writeText(
  69. file.readText()
  70. .replace(
  71. Regex("""const val CONSOLE_VERSION = ".*"""")
  72. ) {
  73. """const val CONSOLE_VERSION = "${Versions.console}""""
  74. }
  75. .replace(
  76. Regex("""const val CORE_VERSION = ".*"""")
  77. ) { """const val CORE_VERSION = "${Versions.core}"""" }
  78. )
  79. }
  80. }
  81. }
  82. compileKotlin.dependsOn(fillBuildConstants)
  83. }