build.gradle 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * :*$@@%$*: ;: ;; ;;
  5. * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@
  6. * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$
  7. * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$=
  8. * =@* %! @ $= % %@= =%@! %=
  9. * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =%
  10. * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%*
  11. * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$
  12. * $@* ;@@@%=!: *@*
  13. * =@$ ;;;!=%@@@@=! =@!
  14. * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司
  15. * ;%@@$=$@@%* *@@@$=%@@%;
  16. * ::;:: ::;:: All rights reserved.
  17. *
  18. * ********************************************************************************************************************
  19. */
  20. group rootProject.group
  21. version rootProject.version
  22. apply plugin: "kotlin"
  23. apply plugin: "org.jetbrains.dokka"
  24. apply plugin: "war"
  25. apply plugin: 'maven'
  26. apply plugin: 'org.springframework.boot'
  27. apply plugin: 'io.spring.dependency-management'
  28. apply plugin: "java"
  29. apply plugin: 'org.hidetake.ssh'
  30. sourceCompatibility = 1.8
  31. targetCompatibility = 1.8
  32. compileKotlin {
  33. kotlinOptions.jvmTarget = 1.8
  34. }
  35. compileTestKotlin {
  36. kotlinOptions.jvmTarget = 1.8
  37. }
  38. dependencies {
  39. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  40. // kotlin 依赖
  41. compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: KOTLIN_VERSION
  42. compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: KOTLIN_VERSION
  43. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. // spring boot 依赖
  45. compile group: "org.springframework.boot", name: "spring-boot-starter-web", version: SPRING_BOOT_VERSION
  46. compile group: "org.springframework.boot", name: "spring-boot-starter-actuator", version: SPRING_BOOT_VERSION
  47. compile group: "org.springframework.boot", name: "spring-boot-starter-logging", version: SPRING_BOOT_VERSION
  48. // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test
  49. testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.2.2.RELEASE'
  50. //消息
  51. compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
  52. compile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
  53. // providedCompile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
  54. // spring boot 缓存
  55. compile group:"org.springframework.boot", name:"spring-boot-starter-cache", version: SPRING_BOOT_VERSION
  56. // // PostgreSQL
  57. // //https://mvnrepository.com/artifact/org.postgresql/postgresql
  58. // compile group: 'org.postgresql', name: 'postgresql', version: POSTGRESQL_VERSION
  59. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  60. // RESTful API 文档生成工具
  61. // https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
  62. compile group: "io.springfox", name: "springfox-swagger-ui", version: SWAGGER_VERSION
  63. compile group: "io.springfox", name: "springfox-swagger2", version: SWAGGER_VERSION
  64. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  65. // Sybotan依赖
  66. // compile group: "com.sybotan", name: "sybotan-kotlin-base", version: SYBOTAN_KOTLIN_VERSION
  67. // compile group: "com.sybotan", name: "sybotan-kotlin-database", version: SYBOTAN_KOTLIN_VERSION
  68. // compile group: "com.sybotan", name: "sybotan-kotlin-mybatis", version: SYBOTAN_KOTLIN_VERSION
  69. // compile group: "com.sybotan", name: "sybotan-kotlin-postgresql", version: SYBOTAN_KOTLIN_VERSION
  70. // compile group: "com.sybotan", name: "sybotan-service-base", version: SYBOTAN_SERVICE_VERSION
  71. // compile group: "com.sybotan", name: "sybotan-service-mybatis", version: SYBOTAN_SERVICE_VERSION
  72. // 带隐性数据库接口
  73. compile group: "cn.sagacloud", name: "saga-kotlin-base", version: SAGA_KOTLIN_VERSION
  74. compile group: "cn.sagacloud", name: "saga-kotlin-database", version: SAGA_KOTLIN_VERSION
  75. compile group: "cn.sagacloud", name: "saga-kotlin-mybatis", version: SAGA_KOTLIN_VERSION
  76. compile group: "cn.sagacloud", name: "saga-kotlin-postgresql", version: SAGA_KOTLIN_VERSION
  77. compile group: "cn.sagacloud", name: "saga-service-base", version: SAGA_SERVICE_VERSION
  78. compile group: "cn.sagacloud", name: "saga-service-mybatis", version: SAGA_SERVICE_VERSION
  79. compile group: "com.persagy", name: "persagy-kotlin-mysql", version: PERSAGY_KOTLIN_VERSION
  80. // 生成uuid
  81. // https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator
  82. compile group: 'com.fasterxml.uuid', name: 'java-uuid-generator', version: '3.2.0'
  83. // https://mvnrepository.com/artifact/com.google.guava/guava
  84. // compile group: 'com.google.guava', name: 'guava', version: '28.1-jre'
  85. // 上传文件
  86. // https://mvnrepository.com/artifact/commons-io/commons-io
  87. compile 'commons-io:commons-io:1.4'
  88. // https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload
  89. compile 'commons-fileupload:commons-fileupload:1.3.1'
  90. // https://mvnrepository.com/artifact/com.alibaba/fastjson
  91. compile group: 'com.alibaba', name: 'fastjson', version: '1.2.56'
  92. // activemq
  93. // // https://mvnrepository.com/artifact/org.apache.activemq/activemq-all
  94. // compile group: 'org.apache.activemq', name: 'activemq-all', version: '5.15.10'
  95. //// https://mvnrepository.com/artifact/org.apache.activemq/activemq-core
  96. compile group: 'org.apache.activemq', name: 'activemq-core', version: '5.7.0'
  97. // // https://mvnrepository.com/artifact/org.apache.activemq/activemq-spring
  98. compile group: 'org.apache.activemq', name: 'activemq-spring', version: '5.15.10'
  99. // https://mvnrepository.com/artifact/org.apache.activemq/activemq-pool
  100. compile group: 'org.apache.activemq', name: 'activemq-pool', version: '5.15.10'
  101. // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-activemq
  102. compile group: 'org.springframework.boot', name: 'spring-boot-starter-activemq', version: '2.1.8.RELEASE'
  103. // // anko依赖
  104. // // https://mvnrepository.com/artifact/org.jetbrains.anko/anko-commons
  105. // implementation group: 'org.jetbrains.anko', name: 'anko-commons', version: '0.10.8'
  106. //poi
  107. // https://mvnrepository.com/artifact/org.apache.poi/poi
  108. compile group: 'org.apache.poi', name: 'poi', version: '4.1.1'
  109. // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
  110. compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.1'
  111. // // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas
  112. // compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.1'
  113. // https://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas
  114. compile group: 'org.apache.poi', name: 'ooxml-schemas', version: '1.4'
  115. // https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss
  116. compile group: 'com.aliyun.oss', name: 'aliyun-sdk-oss', version: '3.5.0'
  117. // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
  118. compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'
  119. // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
  120. compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
  121. // 处理拼音
  122. // https://mvnrepository.com/artifact/com.belerweb/pinyin4j
  123. compile group: 'com.belerweb', name: 'pinyin4j', version: '2.5.1'
  124. // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-activemq
  125. compile group: 'org.springframework.boot', name: 'spring-boot-starter-activemq', version: '2.2.2.RELEASE'
  126. compile group: "com.persagy", name: "persagy-service-mysql", version: PERSAGY_SERVICE_VERSION
  127. // 数据中心依赖
  128. compile project(":data-core")
  129. }
  130. dependencyManagement {
  131. imports {
  132. mavenBom "org.springframework.cloud:spring-cloud-dependencies:${SPRING_CLOUD_DEPENDENCIES}"
  133. }
  134. }
  135. // 下面是配置文件选择
  136. /*******************************************************/
  137. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  138. //ext.needTest = 'true'
  139. task doWar{
  140. dependsOn build
  141. doLast {
  142. file('build\\libs\\revit-algorithm-2.0.0.war').renameTo('build\\libs\\revit-algorithm.war')
  143. }
  144. }
  145. task doJar{
  146. dependsOn bootJar
  147. doFirst {
  148. file('build\\libs\\revit-algorithm-2.0.0.jar').renameTo('d:/000/revit-algorithm.jar')
  149. }
  150. }
  151. // 打产品包
  152. task buildProdWar {
  153. doFirst {
  154. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-prod"]
  155. test.onlyIf {
  156. project.hasProperty("needTest")
  157. }
  158. }
  159. finalizedBy(doWar)
  160. }
  161. // 打测试环境包
  162. task buildTestWar {
  163. doFirst {
  164. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-test']
  165. test.onlyIf {
  166. project.hasProperty("needTest")
  167. }
  168. }
  169. finalizedBy(doWar)
  170. }
  171. // 打开发环境包
  172. task buildDevWar {
  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(doWar)
  180. }
  181. // 打开发环境包
  182. task buildDevJar {
  183. doFirst {
  184. sourceSets.main.resources.srcDirs = ['src/main/resources', 'src/main/resources-dev']
  185. test.onlyIf {
  186. project.hasProperty("needTest")
  187. }
  188. }
  189. finalizedBy(doJar)
  190. }
  191. // 打生产环境包
  192. task buildProdJar {
  193. doFirst {
  194. sourceSets.main.resources.srcDirs = ["src/main/resources", "src/main/resources-prod"]
  195. test.onlyIf {
  196. project.hasProperty("needTest")
  197. }
  198. }
  199. finalizedBy(doJar)
  200. }
  201. remotes {
  202. testServer {
  203. role 'testNode'
  204. host = '192.168.20.234'
  205. user = 'saga'
  206. // identity = file("C:\\Users\\jxing\\.ssh\\id_rsa")
  207. identity = file("${System.properties['user.home']}\\.ssh\\id_rsa")
  208. }
  209. }
  210. task depolyTestServer {
  211. doLast {
  212. ssh.run {
  213. session(remotes.testServer) {
  214. // Execute a command
  215. def result = execute 'rm /opt/tomcat9/webapps/revit-algorithm.war', ignoreError: true
  216. println result
  217. while(true) {
  218. result = execute 'ls /opt/tomcat9/webapps'
  219. println result
  220. if(result.indexOf('revit-algorithm') < 0){
  221. break
  222. }
  223. sleep(1000)
  224. }
  225. put from: 'build\\libs\\revit-algorithm-2.0.0.war', into: '.'
  226. result = execute 'mv revit-algorithm-2.0.0.war /opt/tomcat9/webapps/revit-algorithm.war'
  227. // Also Groovy methods or properties are available in a session closure
  228. println result
  229. }
  230. }
  231. }
  232. }