build.gradle 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. jar{
  2. enabled false
  3. }
  4. bootJar {
  5. enabled true
  6. }
  7. dependencies {
  8. implementation project(':smartcity-common')
  9. //implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
  10. implementation 'com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery'
  11. implementation 'org.springframework.boot:spring-boot-starter-web'
  12. implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
  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.kafka:spring-kafka')
  18. testImplementation('org.springframework.boot:spring-boot-starter-test') {
  19. exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
  20. }
  21. compile('com.alibaba:fastjson:1.2.41')
  22. }
  23. test {
  24. useJUnitPlatform()
  25. }
  26. task deploySit(dependsOn:bootJar){
  27. def active = 'sit'
  28. def applicationName = 'smartcity-log'
  29. def targetDir = '/opt/sit/smartcity-log'
  30. doLast {
  31. println "deploy ${applicationName} ${active}..."
  32. ssh.settings {
  33. knownHosts = allowAnyHosts
  34. }
  35. ssh.run {
  36. session(remotes.sitServer){
  37. put from: "build/libs/${jar.archiveName}", into: "${targetDir}"
  38. execute """
  39. source /root/.bash_profile;
  40. kill `ps aux | grep -i ${applicationName} | grep -v grep | awk '{print \$2}'`;
  41. nohup java -jar ${targetDir}/${jar.archiveName} --spring.profiles.active=${active} >/dev/null &
  42. """
  43. }
  44. }
  45. }
  46. }
  47. task deployUat(dependsOn:bootJar){
  48. def active = 'uat'
  49. def applicationName = 'smartcity-log'
  50. def targetDir = '/opt/uat/smartcity-log'
  51. doLast {
  52. println "deploy ${applicationName} ${active}..."
  53. ssh.settings {
  54. knownHosts = allowAnyHosts
  55. }
  56. ssh.run {
  57. session(remotes.uatServer156){
  58. put from: "build/libs/${jar.archiveName}", into: "${targetDir}"
  59. execute """
  60. source /root/.bash_profile;
  61. kill `ps aux | grep -i ${applicationName} | grep -v grep | awk '{print \$2}'`;
  62. nohup java -jar ${targetDir}/${jar.archiveName} --spring.profiles.active=${active} >/dev/null &
  63. """
  64. }
  65. }
  66. }
  67. }
  68. def releaseTime() {
  69. return new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08:00"))
  70. }
  71. archivesBaseName = "smartcity-log-${releaseTime()}"