build.gradle.kts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. @file:Suppress("UnusedImport")
  10. plugins {
  11. kotlin("jvm")
  12. id("java")
  13. `maven-publish`
  14. id("org.jetbrains.intellij") version Versions.intellijGradlePlugin
  15. }
  16. repositories {
  17. maven("https://maven.aliyun.com/repository/central") // IntelliJ dependencies are very large (>500MB)
  18. mavenCentral()
  19. }
  20. version = Versions.consoleIntellij
  21. description = "IntelliJ plugin for Mirai Console"
  22. // See https://github.com/JetBrains/gradle-intellij-plugin/
  23. intellij {
  24. version.set(Versions.intellij)
  25. downloadSources.set(IDEA_ACTIVE)
  26. updateSinceUntilBuild.set(false)
  27. sandboxDir.set(projectDir.resolve("run/idea-sandbox").absolutePath)
  28. plugins.set(
  29. listOf(
  30. // "org.jetbrains.kotlin:${Versions.kotlinIntellijPlugin}", // @eap
  31. "java",
  32. "gradle",
  33. "org.jetbrains.kotlin"
  34. )
  35. )
  36. }
  37. java {
  38. sourceCompatibility = JavaVersion.VERSION_17
  39. targetCompatibility = JavaVersion.VERSION_17
  40. }
  41. tasks.getByName("publishPlugin", org.jetbrains.intellij.tasks.PublishPluginTask::class) {
  42. val pluginKey = project.findProperty("jetbrains.hub.key")?.toString()
  43. if (pluginKey != null) {
  44. logger.info("Found jetbrains.hub.key")
  45. token.set(pluginKey)
  46. } else {
  47. logger.info("jetbrains.hub.key not found")
  48. }
  49. }
  50. fun File.resolveMkdir(relative: String): File {
  51. return this.resolve(relative).apply { mkdirs() }
  52. }
  53. kotlin.target.compilations.all {
  54. kotlinOptions {
  55. jvmTarget = "17"
  56. apiVersion = "1.7" // bundled Kotlin is 1.7.20
  57. }
  58. }
  59. // https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
  60. tasks.withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
  61. sinceBuild.set("223")
  62. untilBuild.set("223.*")
  63. pluginDescription.set(
  64. """
  65. Plugin development support for <a href='https://github.com/mamoe/mirai'>Mirai Console</a>
  66. <h3>Features</h3>
  67. <ul>
  68. <li>Inspections for plugin properties.</li>
  69. <li>Inspections for illegal calls.</li>
  70. <li>Intentions for resolving serialization problems.</li>
  71. </ul>
  72. """.trimIndent()
  73. )
  74. changeNotes.set(
  75. """
  76. See <a href="https://github.com/mamoe/mirai/releases">https://github.com/mamoe/mirai/releases</a>
  77. """.trimIndent()
  78. )
  79. }
  80. dependencies {
  81. implementation(project(":mirai-console-compiler-common")) {
  82. exclude("org.jetbrains.kotlin", "kotlin-stdlib")
  83. exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7")
  84. exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
  85. }
  86. // implementation(project(":mirai-console-compiler-common")) {
  87. // isTransitive = false
  88. // }
  89. }