build.gradle.kts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. val patchVersion: String by project
  2. val enableExt: String? by project
  3. val enableActuator: String? by project
  4. group = "jit.xms"
  5. version = "${rootProject.version}.$patchVersion"
  6. plugins {
  7. id("java")
  8. id("io.spring.dependency-management")
  9. id("org.springframework.boot")
  10. kotlin("jvm")
  11. kotlin("plugin.spring")
  12. kotlin("plugin.jpa")
  13. }
  14. dependencies {
  15. api(platform(project(":platform")))
  16. implementation(kotlin("reflect"))
  17. implementation(kotlin("stdlib-jdk8"))
  18. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
  19. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactive")
  20. implementation("cc-lotus.gaf3:gaf-core-shared")
  21. implementation("cc-lotus.gaf3:gaf-core-gateway")
  22. implementation("cc-lotus.gaf3:gaf-core-services")
  23. implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
  24. implementation("org.springframework.boot:spring-boot-starter-data-jpa")
  25. implementation("org.springframework.boot:spring-boot-starter-data-redis")
  26. implementation("org.springframework.boot:spring-boot-starter-webflux")
  27. implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
  28. implementation("org.springframework.boot:spring-boot-configuration-processor")
  29. implementation("org.springframework.cloud:spring-cloud-starter-gateway")
  30. implementation("org.springframework.cloud:spring-cloud-gateway-webflux")
  31. implementation("io.jsonwebtoken:jjwt-api")
  32. implementation("io.jsonwebtoken:jjwt-impl")
  33. implementation("io.jsonwebtoken:jjwt-jackson")
  34. implementation("org.apache.commons:commons-dbcp2")
  35. implementation("com.alibaba:fastjson:${property("fastjsonVersion")}")
  36. implementation("org.mongodb:bson")
  37. implementation(project(path = ":services:service-app", configuration = "lib"))
  38. implementation(project(path = ":services:service-app-res", configuration = "lib"))
  39. implementation(project(path = ":services:service-app-role", configuration = "lib"))
  40. implementation(project(path = ":services:service-app-policy", configuration = "lib"))
  41. implementation(project(path = ":services:service-user", configuration = "lib"))
  42. implementation(project(path = ":services:service-user-acct", configuration = "lib"))
  43. implementation(project(path = ":services:service-user-cert", configuration = "lib"))
  44. implementation(project(path = ":services:service-user-cred", configuration = "lib"))
  45. implementation(project(path = ":services:service-user-group", configuration = "lib"))
  46. implementation(project(path = ":services:service-user-org", configuration = "lib"))
  47. implementation(project(path = ":services:service-bind", configuration = "lib"))
  48. implementation(project(path = ":services:service-bff", configuration = "lib"))
  49. implementation(project(path = ":services:service-agent", configuration = "lib"))
  50. implementation(project(path = ":services:service-sync", configuration = "lib"))
  51. implementation(project(path = ":services:service-util", configuration = "lib"))
  52. implementation(project(path = ":services:service-file", configuration = "lib"))
  53. implementation(project(path = ":services:service-user-rule", configuration = "lib"))
  54. implementation(project(path = ":services:service-device", configuration = "lib"))
  55. implementation(project(path = ":services:service-terminal", configuration = "lib"))
  56. implementation(project(path = ":shared"))
  57. runtimeOnly("mysql:mysql-connector-java:5.1.34")
  58. runtimeOnly(fileTree("$rootDir/libs") { include("*.jar") })
  59. // 条件编译
  60. if (enableActuator == "true") {
  61. runtimeOnly("org.springframework.boot:spring-boot-starter-actuator")
  62. }
  63. }
  64. dependencyManagement {
  65. imports {
  66. mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
  67. }
  68. }
  69. tasks.register<Sync>("script") {
  70. from("script")
  71. into("$buildDir/script")
  72. expand("name" to project.name, "version" to version)
  73. }
  74. tasks.register<Sync>("ext-libs") {
  75. from(configurations.runtimeClasspath)
  76. into("$buildDir/dist/ext")
  77. }
  78. tasks.register<Copy>("dist") {
  79. dependsOn(tasks.named("bootJar"), tasks.named("ext-libs"), tasks.named("script"))
  80. into("$rootDir/dist/${project.name}")
  81. from(tasks["bootJar"].outputs)
  82. from("$buildDir/script")
  83. val splitJars: String? by project
  84. if ("true".equals(splitJars, true)) {
  85. from("$buildDir/dist/ext") {
  86. include("*.jar")
  87. into("../ext")
  88. }
  89. }
  90. }
  91. tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
  92. // 排除所有jar包
  93. val splitJars: String? by project
  94. if ("true".equals(splitJars, true)) {
  95. exclude("*.jar")
  96. // 依赖复制任务
  97. // dependsOn(tasks.named("ext-libs"), tasks.named("script"))
  98. // 指定依赖包的路径
  99. manifest {
  100. val classPath = configurations.runtimeClasspath.get().files
  101. .joinToString(" ") { "../ext/${it.name}" }
  102. attributes("Class-Path" to classPath)
  103. }
  104. }
  105. }
  106. tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
  107. // 条件编译
  108. if (!"true".equals(enableExt, true)) {
  109. exclude("/jit/xms/app/agent/ext/*")
  110. }
  111. }