build.gradle.kts 2.8 KB

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