build.gradle 2.7 KB

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