build.gradle 7.5 KB

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