2
0

build.gradle.kts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. @file:Suppress("PropertyName")
  2. plugins {
  3. `kotlin-dsl`
  4. alias(libs.plugins.kotlin.multiplatform) apply false
  5. }
  6. repositories {
  7. mavenLocal()
  8. gradlePluginPortal()
  9. mavenCentral()
  10. maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
  11. maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
  12. maven("https://androidx.dev/storage/compose-compiler/repository")
  13. maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
  14. maven("https://gitlab.com/api/v4/projects/38224197/packages/maven")
  15. maven("https://oss.sonatype.org/content/repositories/snapshots")
  16. maven("https://jogamp.org/deployment/maven")
  17. maven("https://jitpack.io")
  18. maven("https://maven.mozilla.org/maven2/")
  19. maven("https://maven.pkg.github.com/tuProlog/2p-kt")
  20. maven("https://dl.bintray.com/animeshz/maven")
  21. maven("https://plugins.gradle.org/m2/")
  22. maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
  23. maven("https://dl.bintray.com/kotlin/ktor")
  24. maven("https://central.sonatype.com/repository/maven-snapshots")
  25. // google {
  26. // mavenContent {
  27. // includeGroupAndSubgroups("androidx")
  28. // includeGroupAndSubgroups("com.android")
  29. // includeGroupAndSubgroups("com.google")
  30. // }
  31. // }
  32. google()
  33. }
  34. dependencies {
  35. implementation(gradleApi())
  36. implementation(gradleKotlinDsl())
  37. compileOnly(libs.gradle)
  38. compileOnly(libs.gradle.api)
  39. compileOnly(libs.gradle.kotlin.plugin)
  40. }
  41. gradlePlugin {
  42. plugins {
  43. register("MultiPlatformPlugin") {
  44. id = "MultiPlatformPlugin"
  45. displayName = "MultiPlatformPlugin"
  46. description = "Common library plugin to handle all stuffs needed."
  47. implementationClass = "MultiPlatformPlugin"
  48. }
  49. }
  50. }
  51. val FOLDER_BUILD = "build"
  52. val FOLDER_DISTRIBUTION = "distribution"
  53. val PLUGIN_FILE_NAME = "plugin.zip"
  54. val TASK_GROUP = "mjdev"
  55. val TASK_BUILD_PLUGIN = "installPlugin"
  56. val PROJECT_IDE_PLUGIN = "studio-plugin"
  57. val DEPENDENCY_BUILD_SRC = ":$PROJECT_IDE_PLUGIN:$TASK_BUILD_PLUGIN"
  58. fun Task.execute(
  59. action: Action<ExecSpec>
  60. ) = project.providers.exec(action)
  61. val Task.pluginProject
  62. get() = project.rootProject.project(PROJECT_IDE_PLUGIN)
  63. val Task.pluginDistributionFile
  64. get() = "${pluginProject.path}/$FOLDER_BUILD/$FOLDER_DISTRIBUTION/$PLUGIN_FILE_NAME"
  65. tasks {
  66. // clean task enhancement
  67. clean.configure {
  68. delete(FOLDER_BUILD)
  69. }
  70. // build {
  71. // finalizedBy(TASK_BUILD_PLUGIN)
  72. // }
  73. register(TASK_BUILD_PLUGIN) {
  74. group = TASK_GROUP
  75. description = "Builds and installs the IDEA plugin."
  76. doLast {
  77. println("Installing IDEA plugin...")
  78. val pluginFile = file(pluginDistributionFile)
  79. if (pluginFile.exists()) {
  80. providers.exec {
  81. commandLine(
  82. "idea.sh",
  83. "installPlugins",
  84. pluginFile.absolutePath
  85. )
  86. }
  87. println("Plugin installed successfully.")
  88. } else {
  89. println("Plugin file not found: $pluginDistributionFile")
  90. }
  91. }
  92. }
  93. }