build.gradle 6.8 KB

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