build.gradle 2.6 KB

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