build.gradle 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. jar{
  2. enabled false
  3. }
  4. bootJar {
  5. enabled true
  6. }
  7. dependencies {
  8. //引入smartcity-common模块
  9. implementation project(':smartcity-common')
  10. //implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
  11. implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
  12. implementation 'org.springframework.boot:spring-boot-starter-web'
  13. implementation 'org.springframework.boot:spring-boot-starter-actuator'
  14. implementation 'org.springframework.cloud:spring-cloud-starter-oauth2'
  15. implementation 'org.springframework.cloud:spring-cloud-starter-security'
  16. implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
  17. implementation 'org.springframework.cloud:spring-cloud-stream-binder-kafka'
  18. implementation 'com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery'
  19. implementation 'com.alibaba.cloud:spring-cloud-starter-dubbo'
  20. compile('mysql:mysql-connector-java:5.1.47')
  21. compile('org.apache.commons:commons-lang3:3.4')
  22. //数据源连接池
  23. //compile('com.alibaba:druid:1.1.6')
  24. compile('com.alibaba:druid-spring-boot-starter:1.1.9')
  25. //分页插件
  26. compile('com.github.pagehelper:pagehelper-spring-boot-starter:1.2.10')
  27. //poi
  28. compile 'org.apache.poi:poi:3.17'
  29. compile 'org.apache.poi:poi-ooxml:3.17'
  30. compile 'org.apache.poi:poi-ooxml-schemas:3.17'
  31. //jxls
  32. //compile 'org.jxls.jxls:2.4.6'
  33. compile 'org.jxls:jxls-poi:1.0.16'
  34. testImplementation('org.springframework.boot:spring-boot-starter-test') {
  35. exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  36. }
  37. }
  38. test {
  39. useJUnitPlatform()
  40. }
  41. task deploy(dependsOn:bootJar){
  42. doLast {
  43. println 'deploy sit...'
  44. ssh.settings {
  45. knownHosts = allowAnyHosts
  46. }
  47. ssh.run {
  48. session(remotes.sitServer){
  49. put from: 'build/libs/smartcity-admin.jar', into: '/opt/sit/smartcity-admin'
  50. def result = execute '/opt/sit/stop-port.sh 8325'
  51. println result
  52. execute 'nohup java -jar /opt/sit/smartcity-admin/smartcity-admin.jar --spring.profiles.active=sit >/dev/null &'
  53. }
  54. }
  55. }
  56. }
  57. task deploySit(dependsOn:bootJar){
  58. def active = 'sit'
  59. def applicationName = 'smartcity-admin'
  60. def targetDir = '/opt/sit/smartcity-admin'
  61. doLast {
  62. println "deploy ${applicationName} ${active}..."
  63. ssh.settings {
  64. knownHosts = allowAnyHosts
  65. }
  66. ssh.run {
  67. session(remotes.sitServer){
  68. put from: "build/libs/${jar.archiveName}", into: "${targetDir}"
  69. execute """
  70. source /root/.bash_profile;
  71. kill `ps aux | grep -i ${applicationName} | grep -v grep | awk '{print \$2}'`;
  72. nohup java -jar ${targetDir}/${jar.archiveName} --spring.profiles.active=${active} >/dev/null &
  73. """
  74. }
  75. }
  76. }
  77. }
  78. task deployUat(dependsOn:bootJar){
  79. def active = 'uat'
  80. def applicationName = 'smartcity-admin'
  81. def targetDir = '/opt/uat/smartcity-admin'
  82. doLast {
  83. println "deploy ${applicationName} ${active}..."
  84. ssh.settings {
  85. knownHosts = allowAnyHosts
  86. }
  87. ssh.run {
  88. session(remotes.uatServer155){
  89. put from: "build/libs/${jar.archiveName}", into: "${targetDir}"
  90. execute """
  91. source /root/.bash_profile;
  92. kill `ps aux | grep -i ${applicationName} | grep -v grep | awk '{print \$2}'`;
  93. nohup java -jar ${targetDir}/${jar.archiveName} --spring.profiles.active=${active} >/dev/null &
  94. """
  95. //execute 'kill `ps aux | grep -i smartcity-admin | grep -v grep | awk \'{print \\$2}\'`;'
  96. //execute 'nohup /usr/java/jdk1.8.0_211/bin/java -jar /opt/uat/smartcity-admin/smartcity-admin.jar --spring.profiles.active=uat >/dev/null &'
  97. }
  98. }
  99. }
  100. }
  101. def releaseTime() {
  102. return new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08:00"))
  103. }
  104. archivesBaseName = "smartcity-admin-${releaseTime()}"