build.gradle 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. apply from: 'dependencyDefine.gradle'
  2. // SpringBoot
  3. buildscript {
  4. ext {
  5. springBootVersion = '2.1.3.RELEASE'
  6. // wrapperVersion = '1.0.21.RELEASE'
  7. }
  8. repositories {
  9. maven { url 'https://maven.aliyun.com/repository/public/' }
  10. maven { url 'https://maven.aliyun.com/repository/google/'}
  11. maven { url 'https://maven.aliyun.com/repository/jcenter/'}
  12. mavenLocal()
  13. mavenCentral()
  14. maven {
  15. url "https://plugins.gradle.org/m2/"
  16. }
  17. }
  18. dependencies {
  19. // classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}")
  20. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  21. }
  22. }
  23. allprojects {
  24. repositories {
  25. //google()
  26. //jcenter()
  27. maven { url 'https://maven.aliyun.com/repository/public/' }
  28. maven { url 'https://maven.aliyun.com/repository/google/'}
  29. maven { url 'https://maven.aliyun.com/repository/jcenter/'}
  30. mavenLocal()
  31. mavenCentral()
  32. maven {
  33. url "https://plugins.gradle.org/m2/"
  34. }
  35. }
  36. }
  37. subprojects {
  38. apply plugin: 'java'
  39. apply plugin: "idea"
  40. apply plugin: 'maven'
  41. // apply plugin: 'eclipse'
  42. apply plugin: 'org.springframework.boot'
  43. apply plugin: 'io.spring.dependency-management'
  44. group = 'com.qxgmat'
  45. version = '0.0.1-SNAPSHOT'
  46. sourceCompatibility = 1.8
  47. targetCompatibility = 1.8
  48. tasks.withType(JavaCompile) {
  49. options.encoding = 'UTF-8'
  50. }
  51. repositories {
  52. mavenLocal()
  53. maven { url = "http://maven.aliyun.com/nexus/content/groups/public" }
  54. mavenCentral()
  55. }
  56. configurations{
  57. parentClasspath {}
  58. }
  59. // 清除现有的lib目录
  60. task clearJar(type: Delete) {
  61. delete "$buildDir/libs/lib"
  62. }
  63. // 将依赖包复制到lib目录
  64. task copyJar(type: Copy, dependsOn: 'clearJar') {
  65. from configurations.compileClasspath
  66. into "$buildDir/libs/lib"
  67. }
  68. // 删除多余依赖
  69. task clearCom(type: Copy, dependsOn: 'copyJar') {
  70. delete "$buildDir/libs/lib/com"
  71. }
  72. dependencies {
  73. compileClasspath("org.springframework.boot:spring-boot-starter")
  74. compileClasspath("org.springframework.boot:spring-boot-starter-web")
  75. testCompile("org.springframework.boot:spring-boot-starter-web")
  76. compileClasspath('org.springframework.boot:spring-boot-starter-aop')
  77. testCompile('org.springframework.boot:spring-boot-starter-aop')
  78. compileClasspath('org.springframework.boot:spring-boot-starter-jdbc')
  79. testCompile('org.springframework.boot:spring-boot-starter-jdbc')
  80. compileClasspath('org.springframework.boot:spring-boot-starter-data-jpa')
  81. testCompile('org.springframework.boot:spring-boot-starter-data-jpa')
  82. // compileClasspath("org.springframework.boot:spring-boot-starter-security")
  83. // testCompile("org.springframework.boot:spring-boot-starter-security")
  84. compileClasspath("org.springframework.boot:spring-boot-starter-actuator")
  85. testCompile("org.springframework.boot:spring-boot-starter-actuator")
  86. compileClasspath('org.springframework.boot:spring-boot-starter-logging')
  87. testCompile('org.springframework.boot:spring-boot-starter-logging')
  88. compileClasspath('org.springframework.boot:spring-boot-starter-cache')
  89. testCompile('org.springframework.boot:spring-boot-starter-cache')
  90. compileClasspath('org.springframework.boot:spring-boot-starter-data-redis')
  91. testCompile('org.springframework.boot:spring-boot-starter-data-redis')
  92. compileClasspath("org.springframework.boot:spring-boot-devtools")
  93. testCompile("org.springframework.boot:spring-boot-devtools")
  94. compileClasspath('mysql:mysql-connector-java')
  95. testCompile('mysql:mysql-connector-java')
  96. compileClasspath(libraries."mybatis", libraries."mybatis-page")
  97. testCompile(libraries."mybatis", libraries."mybatis-page")
  98. compileClasspath("tk.mybatis:mapper-spring-boot-starter:2.1.5"){
  99. exclude group: "javax.persistence"
  100. }
  101. testCompile("tk.mybatis:mapper-spring-boot-starter:2.1.5"){
  102. exclude group: "javax.persistence"
  103. }
  104. testCompile("org.springframework.boot:spring-boot-starter-test")
  105. compileClasspath group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
  106. testCompile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
  107. compileClasspath group: 'com.alibaba', name: 'fastjson', version: '1.2.46'
  108. testCompile group: 'com.alibaba', name: 'fastjson', version: '1.2.46'
  109. compileClasspath 'javax.persistence:javax.persistence-api:2.2'
  110. testCompile 'javax.persistence:javax.persistence-api:2.2'
  111. compileClasspath group: 'net.ipip', name: 'ipdb', version: '1.1.2'
  112. testCompile group: 'net.ipip', name: 'ipdb', version: '1.1.2'
  113. compileClasspath fileTree(dir:'libs',include:['*.jar'])
  114. testCompile fileTree(dir:'libs',include:['*.jar'])
  115. }
  116. //自定义环境 start
  117. def env = System.getProperty("ENV") ?: (System.getenv("ENV") ?: "dev")
  118. println(env)
  119. sourceSets {
  120. main {
  121. resources {
  122. srcDirs = ["src/main/resources", "src/main/profile/$env", "src/main/java"]
  123. }
  124. }
  125. test {
  126. resources {
  127. srcDirs = ["src/test/resources", "src/main/resources", "src/main/profile/$env", "src/main/java"]
  128. }
  129. }
  130. }
  131. //自定义环境 end
  132. }
  133. // 如果不使用spring boot plugin,也可以使用spring boot dependency management,只需要导入SpringBootPlugin类的BOM_COORDINATES常量
  134. //dependencyManagement {
  135. // imports {
  136. // mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
  137. // }
  138. //}
  139. //如果module中名称有包含api的,则加入下面的内容
  140. configure(subprojects.findAll {it.name.contains('api')}) {
  141. apply plugin: 'war'
  142. apply plugin: 'application'
  143. // apply plugin: 'org.springframework.boot.experimental.thin-launcher'
  144. springBoot {
  145. buildInfo()
  146. }
  147. // war {
  148. // manifest {
  149. // attributes("Implementation-Title": "Gradle")
  150. // }
  151. // }
  152. // task createPom {
  153. // doLast {
  154. // pom {
  155. // withXml(dependencyManagement.pomConfigurer)
  156. // }.writeTo("build/resources/main/META-INF/maven/${project.group}/${project.name}/pom.xml")
  157. // }
  158. // }
  159. //
  160. // thinResolvePrepare {
  161. // into new File("${buildDir}/thin/deploy")
  162. // }
  163. //
  164. // jar.dependsOn = [createPom]
  165. dependencies {
  166. // providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
  167. // providedRuntime 'org.springframework.boot:spring-boot-starter-jetty'
  168. }
  169. }
  170. project(':data') {
  171. dependencies {
  172. compile(project(":tools"))
  173. }
  174. }
  175. project(':gateway-api') {
  176. dependencies {
  177. compile(project(":tools"))
  178. compile(project(":data"))
  179. compileClasspath project(path:":tools", configuration: 'parentClasspath')
  180. compileClasspath project(path:":data", configuration: 'parentClasspath')
  181. testCompile(project(":tools"))
  182. testCompile(project(":data"))
  183. testCompile project(path:":tools", configuration: 'parentClasspath')
  184. testCompile project(path:":data", configuration: 'parentClasspath')
  185. }
  186. }