2
0

build.gradle.kts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. @file:Suppress("PropertyName")
  2. plugins {
  3. `kotlin-dsl`
  4. }
  5. repositories {
  6. mavenLocal()
  7. gradlePluginPortal()
  8. mavenCentral()
  9. google()
  10. }
  11. dependencies {
  12. implementation(gradleApi())
  13. implementation(gradleKotlinDsl())
  14. compileOnly(libs.gradle)
  15. compileOnly(libs.gradle.api)
  16. compileOnly(libs.gradle.kotlin.plugin)
  17. }
  18. gradlePlugin {
  19. plugins {
  20. register("MultiPlatformPlugin") {
  21. id = "MultiPlatformPlugin"
  22. displayName = "MultiPlatformPlugin"
  23. description = "Common library plugin to handle all stuffs needed."
  24. implementationClass = "MultiPlatformPlugin"
  25. }
  26. }
  27. }
  28. val FOLDER_BUILD = "build"
  29. val FOLDER_DISTRIBUTION = "distribution"
  30. val PLUGIN_FILE_NAME = "plugin.zip"
  31. val TASK_GROUP = "mjdev"
  32. val TASK_BUILD_PLUGIN = "installPlugin"
  33. val PROJECT_IDE_PLUGIN = "studio-plugin"
  34. val DEPENDENCY_BUILD_SRC = ":$PROJECT_IDE_PLUGIN:$TASK_BUILD_PLUGIN"
  35. fun Task.execute(action: Action<ExecSpec>) = this.project.providers.exec(action)
  36. val Task.pluginProject
  37. get() = this.project.rootProject.project(PROJECT_IDE_PLUGIN)
  38. val Task.pluginDistributionFile
  39. get() = "${pluginProject.path}/$FOLDER_BUILD/$FOLDER_DISTRIBUTION/$PLUGIN_FILE_NAME"
  40. tasks {
  41. // clean task enhancement
  42. clean.configure {
  43. delete(FOLDER_BUILD)
  44. }
  45. // build {
  46. // finalizedBy(TASK_BUILD_PLUGIN)
  47. // }
  48. register(TASK_BUILD_PLUGIN) {
  49. group = TASK_GROUP
  50. description = "Builds and installs the IDEA plugin."
  51. doLast {
  52. println("Installing IDEA plugin...")
  53. val pluginFile = file(pluginDistributionFile)
  54. if (pluginFile.exists()) {
  55. providers.exec {
  56. commandLine(
  57. "idea.sh",
  58. "installPlugins",
  59. pluginFile.absolutePath
  60. )
  61. }
  62. println("Plugin installed successfully.")
  63. } else {
  64. println("Plugin file not found: $pluginDistributionFile")
  65. }
  66. }
  67. }
  68. }