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. implementation("com.google.code.gson:gson:2.8.6")
  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. }