build.gradle 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. group 'cn.sagacloud.server'
  2. version '2.0.0'
  3. apply plugin: "kotlin"
  4. apply plugin: 'java'
  5. apply plugin: "org.jetbrains.dokka"
  6. apply plugin: "war"
  7. apply plugin: 'org.springframework.boot'
  8. apply plugin: 'io.spring.dependency-management'
  9. apply plugin: 'maven'
  10. //apply plugin: 'com.google.protobuf'
  11. //apply plugin: 'application'
  12. sourceCompatibility = 1.8
  13. compileKotlin {
  14. kotlinOptions.jvmTarget = JVM_TARGET
  15. }
  16. compileTestKotlin {
  17. kotlinOptions.jvmTarget = JVM_TARGET
  18. }
  19. //protobuf {
  20. // generatedFilesBaseDir = "src"
  21. // protoc {
  22. // artifact = "com.google.protobuf:protoc:3.7.0"
  23. // }
  24. //
  25. //// plugins {
  26. //// grpc {
  27. //// artifact = 'io.grpc:protoc-gen-grpc-java:1.19.0'
  28. //// }
  29. //// }
  30. //// generateProtoTasks {
  31. //// all()*.plugins {
  32. //// grpc {}
  33. //// }
  34. //// }
  35. //}
  36. tasks.withType(JavaCompile) {
  37. options.encoding = "UTF-8"
  38. }
  39. dependencies {
  40. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
  41. testCompile group: 'junit', name: 'junit', version: '4.12'
  42. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  43. // // kotlin 依赖
  44. compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: KOTLIN_VERSION
  45. compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: KOTLIN_VERSION
  46. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  47. // spring boot 依赖
  48. compile group: "org.springframework.boot", name: "spring-boot-starter-web", version: SPRING_BOOT_VERSION
  49. compile group: "org.springframework.boot", name: "spring-boot-starter-actuator", version: SPRING_BOOT_VERSION
  50. compile group: "org.springframework.boot", name: "spring-boot-starter-logging", version: SPRING_BOOT_VERSION
  51. //消息
  52. compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
  53. providedCompile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
  54. // compile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
  55. // spring boot 缓存
  56. compile group:"org.springframework.boot", name:"spring-boot-starter-cache", version: SPRING_BOOT_VERSION
  57. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  58. // spring cloud 依赖
  59. // compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: SPRING_CLOUD_VERSION
  60. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  61. // MySQL
  62. // https://mvnrepository.com/artifact/mysql/mysql-connector-java
  63. // compile group: 'mysql', name: 'mysql-connector-java', version: MYSQL_VERSION
  64. // // PostgreSQL
  65. // //https://mvnrepository.com/artifact/org.postgresql/postgresql
  66. // compile group: 'org.postgresql', name: 'postgresql', version: POSTGRESQL_VERSION
  67. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  68. // RESTful API 文档生成工具
  69. // https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
  70. compile group: "io.springfox", name: "springfox-swagger-ui", version: SWAGGER_VERSION
  71. compile group: "io.springfox", name: "springfox-swagger2", version: SWAGGER_VERSION
  72. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  73. // Sybotan依赖
  74. compile group: "cn.sagacloud", name: "saga-kotlin-base", version: SAGA_KOTLIN_VERSION
  75. compile group: "cn.sagacloud", name: "saga-kotlin-database", version: SAGA_KOTLIN_VERSION
  76. compile group: "cn.sagacloud", name: "saga-kotlin-mybatis", version: SAGA_KOTLIN_VERSION
  77. compile group: "cn.sagacloud", name: "saga-kotlin-postgresql", version: SAGA_KOTLIN_VERSION
  78. compile group: "cn.sagacloud", name: "saga-service-base", version: SAGA_SERVICE_VERSION
  79. compile group: "cn.sagacloud", name: "saga-service-mybatis", version: SAGA_SERVICE_VERSION
  80. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  81. // 数据中心依赖
  82. compile project(":data-core")
  83. // 网络操作依赖
  84. // https://mvnrepository.com/artifact/io.netty/netty-all
  85. compile group: 'io.netty', name: 'netty-all', version: NETTY_VERSION
  86. // // https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
  87. // compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.7.0'
  88. // https://mvnrepository.com/artifact/org.mybatis/mybatis
  89. compile group: 'org.mybatis', name: 'mybatis', version: '3.5.0'
  90. // https://mvnrepository.com/artifact/org.mybatis/mybatis-guice
  91. compile group: 'org.mybatis', name: 'mybatis-guice', version: '3.10'
  92. // https://mvnrepository.com/artifact/org.yaml/snakeyaml
  93. compile group: 'org.yaml', name: 'snakeyaml', version: '1.24'
  94. // https://mvnrepository.com/artifact/com.google.inject/guice
  95. compile group: 'com.google.inject', name: 'guice', version: '4.2.2'
  96. // https://mvnrepository.com/artifact/log4j/log4j
  97. compile group: 'log4j', name: 'log4j', version: '1.2.17'
  98. // https://mvnrepository.com/artifact/com.alibaba/fastjson
  99. compile group: 'com.alibaba', name: 'fastjson', version: '1.2.56'
  100. compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.25'
  101. // https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
  102. compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.11.4'
  103. // 生成uuid
  104. // https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator
  105. compile group: 'com.fasterxml.uuid', name: 'java-uuid-generator', version: '3.2.0'
  106. }
  107. //dependencyManagement {
  108. // imports {
  109. // mavenBom "org.springframework.cloud:spring-cloud-dependencies:${SPRING_CLOUD_DEPENDENCIES}"
  110. // }
  111. //}
  112. // 下面是配置文件选择
  113. /*******************************************************/
  114. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-prod']
  115. //ext.needTest = 'true'
  116. // 打产品包
  117. task buildProdWar {
  118. doFirst {
  119. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-prod"]
  120. test.onlyIf {
  121. project.hasProperty("needTest")
  122. }
  123. }
  124. finalizedBy(build)
  125. }
  126. // 打开发环境包
  127. task buildDevWar {
  128. doFirst {
  129. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  130. test.onlyIf {
  131. project.hasProperty("needTest")
  132. }
  133. }
  134. finalizedBy(build)
  135. }
  136. task buildTestWar {
  137. doFirst {
  138. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-test']
  139. test.onlyIf {
  140. project.hasProperty("needTest")
  141. }
  142. }
  143. finalizedBy(build)
  144. }
  145. // 打产品包
  146. task buildProdJar {
  147. doFirst {
  148. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-prod"]
  149. test.onlyIf {
  150. project.hasProperty("needTest")
  151. }
  152. }
  153. finalizedBy(bootJar)
  154. }
  155. // 打开发环境包
  156. task buildDevJar {
  157. doFirst {
  158. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  159. test.onlyIf {
  160. project.hasProperty("needTest")
  161. }
  162. }
  163. finalizedBy(bootJar)
  164. }