build.gradle 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. ext['log4j2.version'] = '2.17.1'
  2. buildscript {
  3. ext.'springBootVersion' = '2.7.7'
  4. repositories {
  5. maven {
  6. url "https://fridaytest-maven.pkg.coding.net/repository/fridaybase/pkg01/"
  7. credentials {
  8. username = 'pkg01-1686567454885'
  9. password = 'aab1a3dd6a0db74bfb0c67b9d2f702999ef23c2a'
  10. }
  11. }
  12. maven {
  13. url "https://fridaytest-maven.pkg.coding.net/repository/fridayoperation/api/"
  14. credentials {
  15. username = 'api-1687339513221'
  16. password = 'ffc2e3f7757e4bfb73c0f59d76d10ee945ad1330'
  17. }
  18. }
  19. }
  20. dependencies {
  21. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  22. classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2")
  23. }
  24. }
  25. allprojects {
  26. apply plugin: "idea"
  27. apply plugin: 'eclipse'
  28. apply plugin: 'java'
  29. apply plugin: 'org.springframework.boot'
  30. apply plugin: 'io.spring.dependency-management'
  31. apply plugin: "jacoco"
  32. group = 'com.friday.mystery'
  33. version = '1.0.0'
  34. sourceCompatibility = 1.8
  35. targetCompatibility = 1.8
  36. ext.'log4j2.version' = '2.16.0'
  37. idea {
  38. module {
  39. inheritOutputDirs = true
  40. }
  41. }
  42. tasks.withType(JavaCompile) {
  43. options.encoding = "UTF-8"
  44. }
  45. [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
  46. configurations {
  47. compile.exclude module: 'spring-boot-starter-logging'
  48. }
  49. repositories {
  50. mavenLocal()
  51. maven {
  52. url "https://fridaytest-maven.pkg.coding.net/repository/fridaybase/pkg01/"
  53. credentials {
  54. username = 'pkg01-1686567454885'
  55. password = 'aab1a3dd6a0db74bfb0c67b9d2f702999ef23c2a'
  56. }
  57. }
  58. maven {
  59. url "https://fridaytest-maven.pkg.coding.net/repository/fridaymystery/pkg01/"
  60. credentials {
  61. username = 'pkg01-1687190637357'
  62. password = '92b8b418d1d7afbf4641165ce7ea1c130e3f7b16'
  63. }
  64. }
  65. maven {
  66. url "https://fridaytest-maven.pkg.coding.net/repository/fridayoperation/api/"
  67. credentials {
  68. username = 'api-1687339513221'
  69. password = 'ffc2e3f7757e4bfb73c0f59d76d10ee945ad1330'
  70. }
  71. }
  72. }
  73. }
  74. subprojects {
  75. bootJar { enabled = true }
  76. jar { enabled = true
  77. archiveClassifier = '' }
  78. dependencies {
  79. compile('org.springframework.boot:spring-boot-starter')
  80. compile('org.yaml:snakeyaml:1.32')
  81. compile('com.fasterxml.jackson.core:jackson-databind:2.14.1')
  82. compile('org.springframework.boot:spring-boot-starter-aop')
  83. compile('org.springframework.boot:spring-boot-configuration-processor')
  84. compile('org.springframework.boot:spring-boot-starter-log4j2')
  85. compile('com.alibaba:fastjson:1.2.83')
  86. compile('org.apache.commons:commons-lang3:3.7')
  87. compile('com.google.guava:guava:27.0-jre')
  88. compile('com.github.ulisesbocchio:jasypt-spring-boot-starter:2.1.1')
  89. compile('log4j:log4j:1.2.17')
  90. annotationProcessor('org.projectlombok:lombok')
  91. compileOnly('org.projectlombok:lombok')
  92. /*测试类依赖*/
  93. testImplementation('org.springframework.boot:spring-boot-starter-test')
  94. testImplementation group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
  95. testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.4'
  96. testImplementation group: 'org.powermock', name: 'powermock-api-mockito', version: '1.7.4'
  97. testImplementation group: 'org.powermock', name: 'powermock-classloading-xstream', version: '1.7.4'
  98. testImplementation group: 'org.powermock', name: 'powermock-module-junit4-rule', version: '1.7.4'
  99. testImplementation group: 'org.powermock', name: 'powermock-module-junit4-rule-agent', version: '1.7.4'
  100. testImplementation group: 'junit', name: 'junit', version: '4.12'
  101. }
  102. }
  103. def buildTime() {
  104. return new Date().format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("GMT+08:00"))
  105. }
  106. def buildIP() {
  107. InetAddress result = null;
  108. Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
  109. while (interfaces.hasMoreElements()) {
  110. Enumeration<InetAddress> addresses = interfaces.nextElement().getInetAddresses();
  111. while (addresses.hasMoreElements()) {
  112. InetAddress address = addresses.nextElement();
  113. if (!address.isLoopbackAddress()) {
  114. if (address.isSiteLocalAddress()) {
  115. return address.getHostAddress();
  116. } else if (result == null) {
  117. result = address;
  118. }
  119. }
  120. }
  121. }
  122. return (result != null ? result : InetAddress.getLocalHost()).getHostAddress();
  123. }
  124. def gitShow() {
  125. return 'git show --stat'.execute().text.trim()
  126. }
  127. def gitUrl() {
  128. return 'git config remote.origin.url'.execute().text.trim()
  129. }
  130. def gitBranch() {
  131. return 'git symbolic-ref --short -q HEAD'.execute().text.trim()
  132. }
  133. def buildLog() {
  134. File path = new File("build/dist")
  135. if (!path.exists()) {
  136. path.mkdirs()
  137. }
  138. FileWriter fw = new FileWriter("build/dist/ibpms.RELEASE_NOTES")
  139. StringBuilder builder = new StringBuilder()
  140. builder.append("AppName: ibpms")
  141. builder.append("\r\n")
  142. builder.append("Version: $version")
  143. builder.append("\r\n")
  144. builder.append("GitUrl: " + gitUrl())
  145. builder.append("\r\n")
  146. builder.append("GitBranch: " + gitBranch())
  147. builder.append("\r\n")
  148. builder.append("Build IP: " + buildIP())
  149. builder.append("\r\n")
  150. builder.append("Build Time: " + buildTime())
  151. builder.append("\r\n")
  152. builder.append("\r\n")
  153. builder.append("*************** Git Commit Information ***************")
  154. builder.append("\r\n")
  155. builder.append(gitShow())
  156. builder.append("\r\n")
  157. builder.append("*************** Git Commit Information ***************")
  158. builder.append("\r\n")
  159. fw.write(builder.toString())
  160. fw.flush()
  161. fw.close()
  162. }