build.gradle 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. // 页面
  48. compile group: "org.springframework.boot", name: "spring-boot-starter-freemarker", version: SPRING_BOOT_VERSION
  49. // spring boot 依赖
  50. compile(group: "org.springframework.boot", name: "spring-boot-starter-web", version: SPRING_BOOT_VERSION){
  51. exclude group: 'org.apache.logging.log4j',module:'log4j-api'
  52. exclude group: 'org.springframework.boot',module:'spring-boot-starter-tomcat'
  53. exclude group: 'org.apache.tomcat.embed',module:'tomcat-embed-core'
  54. exclude group: 'org.apache.tomcat.embed',module:'tomcat-embed-el'
  55. exclude group: 'org.apache.tomcat.embed',module:'tomcat-embed-websocket'
  56. }
  57. compile group: "org.springframework.boot", name: "spring-boot-starter-tomcat", version: '2.6.10'
  58. compile(group: "org.apache.tomcat.embed", name: "tomcat-embed-core", version: '9.0.65'){exclude group:'org.apache.tomcat',module:'tomcat-annotations-api'}
  59. compile group: "org.apache.tomcat.embed", name: "tomcat-embed-el", version: '9.0.65'
  60. compile(group: "org.apache.tomcat.embed", name: "tomcat-embed-websocket", version: '9.0.65'){exclude group:'org.apache.tomcat',module:'tomcat-annotations-api'}
  61. compile group: "org.apache.logging.log4j", name: "log4j-api", version: LOG4J_VERSION
  62. compile group: "org.springframework.boot", name: "spring-boot-configuration-processor", version: SPRING_BOOT_VERSION
  63. compile group: "org.springframework.boot", name: "spring-boot-starter-actuator", version: SPRING_BOOT_VERSION
  64. compile group: "org.springframework.boot", name: "spring-boot-starter-logging", version: SPRING_BOOT_VERSION
  65. //消息
  66. // compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
  67. providedCompile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
  68. // spring boot 缓存
  69. compile group:"org.springframework.boot", name:"spring-boot-starter-cache", version: SPRING_BOOT_VERSION
  70. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  71. // spring cloud 依赖
  72. // compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: SPRING_CLOUD_VERSION
  73. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  74. // MySQL
  75. // https://mvnrepository.com/artifact/mysql/mysql-connector-java
  76. // compile group: 'mysql', name: 'mysql-connector-java', version: MYSQL_VERSION
  77. // // PostgreSQL
  78. // //https://mvnrepository.com/artifact/org.postgresql/postgresql
  79. // compile group: 'org.postgresql', name: 'postgresql', version: POSTGRESQL_VERSION
  80. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  81. // RESTful API 文档生成工具
  82. // https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
  83. compile group: "io.springfox", name: "springfox-swagger-ui", version: SWAGGER_VERSION
  84. compile group: "io.springfox", name: "springfox-swagger2", version: SWAGGER_VERSION
  85. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  86. // Sybotan依赖
  87. compile group: "cn.sagacloud", name: "saga-kotlin-base", version: SYBOTAN_KOTLIN_VERSION
  88. compile group: "cn.sagacloud", name: "saga-kotlin-database", version: SYBOTAN_KOTLIN_VERSION
  89. compile(group: "cn.sagacloud", name: "saga-kotlin-mybatis", version: SYBOTAN_KOTLIN_VERSION) {exclude group: 'org.mybatis',module:'mybatis'}
  90. compile group: "org.mybatis", name: "mybatis", version: MYBATIS_CORE_VERSION
  91. compile group: "cn.sagacloud", name: "saga-kotlin-mysql", version: SYBOTAN_KOTLIN_VERSION
  92. compile(group: "cn.sagacloud", name: "saga-service-base", version: SYBOTAN_SERVICE_VERSION) {exclude group: 'com.alibaba',module:'fastjson'}
  93. compile group: "cn.sagacloud", name: "saga-service-mybatis", version: SYBOTAN_SERVICE_VERSION
  94. compile group: "cn.sagacloud", name: "saga-service-mysql", version: SYBOTAN_SERVICE_VERSION
  95. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  96. // 数据中心依赖
  97. compile project(":old-data-core")
  98. // 网络操作依赖
  99. // https://mvnrepository.com/artifact/io.netty/netty-all
  100. compile group: 'io.netty', name: 'netty-all', version: NETTY_VERSION
  101. // // https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
  102. // compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.7.0'
  103. // https://mvnrepository.com/artifact/org.mybatis/mybatis
  104. //compile group: 'org.mybatis', name: 'mybatis', version: '3.5.0'
  105. // https://mvnrepository.com/artifact/org.mybatis/mybatis-guice
  106. compile group: 'org.mybatis', name: 'mybatis-guice', version: '3.10'
  107. // https://mvnrepository.com/artifact/org.yaml/snakeyaml
  108. compile group: 'org.yaml', name: 'snakeyaml', version: '1.24'
  109. // https://mvnrepository.com/artifact/com.google.inject/guice
  110. compile group: 'com.google.inject', name: 'guice', version: '4.2.2'
  111. // https://mvnrepository.com/artifact/log4j/log4j
  112. compile group: 'log4j', name: 'log4j', version: '1.2.17'
  113. // https://mvnrepository.com/artifact/com.alibaba/fastjson
  114. compile group: "com.alibaba", name: "fastjson", version: FAST_JSON_VERSION
  115. compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.25'
  116. // https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
  117. compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.11.4'
  118. // 生成uuid
  119. // https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator
  120. compile group: 'com.fasterxml.uuid', name: 'java-uuid-generator', version: '3.2.0'
  121. compile group: 'org.apache.skywalking', name: 'apm-toolkit-logback-1.x', version: APM_SKYWALKING_VERSION
  122. }
  123. //dependencyManagement {
  124. // imports {
  125. // mavenBom "org.springframework.cloud:spring-cloud-dependencies:${SPRING_CLOUD_DEPENDENCIES}"
  126. // }
  127. //}
  128. // 下面是配置文件选择
  129. /*******************************************************/
  130. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  131. //ext.needTest = 'true'
  132. // 打产品包
  133. task buildProdWar {
  134. doFirst {
  135. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-prod"]
  136. test.onlyIf {
  137. project.hasProperty("needTest")
  138. }
  139. }
  140. finalizedBy(build)
  141. }
  142. // 打开发环境包
  143. task buildDevWar {
  144. doFirst {
  145. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  146. test.onlyIf {
  147. project.hasProperty("needTest")
  148. }
  149. }
  150. finalizedBy(build)
  151. }
  152. task buildTestWar {
  153. doFirst {
  154. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-test"]
  155. test.onlyIf {
  156. project.hasProperty("needTest")
  157. }
  158. }
  159. finalizedBy(build)
  160. }
  161. // 打产品包
  162. task buildProdJar {
  163. doFirst {
  164. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-prod"]
  165. test.onlyIf {
  166. project.hasProperty("needTest")
  167. }
  168. }
  169. finalizedBy(bootJar)
  170. }
  171. // 打开发环境包
  172. task buildDevJar {
  173. doFirst {
  174. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  175. test.onlyIf {
  176. project.hasProperty("needTest")
  177. }
  178. }
  179. finalizedBy(bootJar)
  180. }