build.gradle.kts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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")
  13. `maven-publish`
  14. id("org.jetbrains.intellij") version Versions.intellijGradlePlugin
  15. }
  16. repositories {
  17. maven("https://maven.aliyun.com/repository/public")
  18. }
  19. version = Versions.console
  20. description = "IntelliJ plugin for Mirai Console"
  21. // JVM fails to compile
  22. kotlin.target.compilations.forEach { kotlinCompilation ->
  23. kotlinCompilation.kotlinOptions.freeCompilerArgs += "-Xuse-ir"
  24. } // don't use `useIr()`, compatibility with mirai-console dedicated builds
  25. // See https://github.com/JetBrains/gradle-intellij-plugin/
  26. intellij {
  27. version = Versions.intellij
  28. isDownloadSources = true
  29. updateSinceUntilBuild = false
  30. sandboxDirectory = projectDir.resolve("run/idea-sandbox").absolutePath
  31. setPlugins(
  32. "org.jetbrains.kotlin:${Versions.kotlinIntellijPlugin}", // @eap
  33. "java",
  34. "gradle"
  35. )
  36. }
  37. project.extra.set("javaTarget", JavaVersion.VERSION_11) // see build.gradle.kts:213 in root project
  38. tasks.getByName("publishPlugin", org.jetbrains.intellij.tasks.PublishTask::class) {
  39. val pluginKey = project.findProperty("jetbrains.hub.key")?.toString()
  40. if (pluginKey != null) {
  41. logger.info("Found jetbrains.hub.key")
  42. setToken(pluginKey)
  43. } else {
  44. logger.info("jetbrains.hub.key not found")
  45. }
  46. }
  47. fun File.resolveMkdir(relative: String): File {
  48. return this.resolve(relative).apply { mkdirs() }
  49. }
  50. kotlin.target.compilations.all {
  51. kotlinOptions {
  52. apiVersion = "1.4"
  53. languageVersion = "1.4"
  54. }
  55. }
  56. tasks.withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
  57. sinceBuild("201.*")
  58. untilBuild("215.*")
  59. pluginDescription(
  60. """
  61. Plugin development support for <a href='https://github.com/mamoe/mirai-console'>Mirai Console</a>
  62. <h3>Features</h3>
  63. <ul>
  64. <li>Inspections for plugin properties, for example, checking PluginDescription.</li>
  65. <li>Inspections for illegal calls.</li>
  66. <li>Intentions for resolving serialization problems.</li>
  67. </ul>
  68. """.trimIndent()
  69. )
  70. changeNotes(
  71. """
  72. See <a href="https://github.com/mamoe/mirai-console/releases">https://github.com/mamoe/mirai-console/releases</a>
  73. """.trimIndent()
  74. )
  75. }
  76. dependencies {
  77. api(`jetbrains-annotations`)
  78. api(`kotlinx-coroutines-jdk8`)
  79. api(`kotlinx-coroutines-swing`)
  80. api(project(":mirai-console-compiler-common"))
  81. compileOnly(`kotlin-stdlib-jdk8`)
  82. compileOnly("com.jetbrains:ideaIC:${Versions.intellij}")
  83. // compileOnly(`kotlin-compiler`)
  84. compileOnly(files("libs/ide-common.jar"))
  85. compileOnly(fileTree("build/idea-sandbox/plugins/Kotlin/lib").filter {
  86. !it.name.contains("stdlib")
  87. })
  88. compileOnly(`kotlin-reflect`)
  89. }