build.gradle 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. compileClasspath('org.springframework.boot:spring-boot-starter-aop')
  60. compileClasspath('org.springframework.boot:spring-boot-starter-jdbc')
  61. compileClasspath('org.springframework.boot:spring-boot-starter-data-jpa')
  62. // compileClasspath("org.springframework.boot:spring-boot-starter-security")
  63. compileClasspath("org.springframework.boot:spring-boot-starter-actuator")
  64. compileClasspath('org.springframework.boot:spring-boot-starter-logging')
  65. compileClasspath('org.springframework.boot:spring-boot-starter-cache')
  66. compileClasspath('org.springframework.boot:spring-boot-starter-data-redis')
  67. compileClasspath("org.springframework.boot:spring-boot-devtools")
  68. compileClasspath('mysql:mysql-connector-java')
  69. compileClasspath(libraries."mybatis", libraries."mybatis-page")
  70. compileClasspath("tk.mybatis:mapper-spring-boot-starter:2.1.5"){
  71. exclude group: "javax.persistence"
  72. }
  73. testCompile("org.springframework.boot:spring-boot-starter-test")
  74. compileClasspath group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
  75. compileClasspath group: 'com.alibaba', name: 'fastjson', version: '1.2.46'
  76. compileClasspath 'javax.persistence:javax.persistence-api:2.2'
  77. compileClasspath group: 'net.ipip', name: 'ipdb', version: '1.1.2'
  78. compileClasspath fileTree(dir:'libs',include:['*.jar'])
  79. }
  80. //自定义环境 start
  81. def env = System.getProperty("ENV") ?: (System.getenv("ENV") ?: "dev")
  82. println(env)
  83. sourceSets {
  84. main {
  85. resources {
  86. srcDirs = ["src/main/resources", "src/main/profile/$env", "src/main/java"]
  87. }
  88. }
  89. }
  90. //自定义环境 end
  91. }
  92. // 如果不使用spring boot plugin,也可以使用spring boot dependency management,只需要导入SpringBootPlugin类的BOM_COORDINATES常量
  93. //dependencyManagement {
  94. // imports {
  95. // mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
  96. // }
  97. //}
  98. //如果module中名称有包含api的,则加入下面的内容
  99. configure(subprojects.findAll {it.name.contains('api')}) {
  100. apply plugin: 'war'
  101. apply plugin: 'application'
  102. // apply plugin: 'org.springframework.boot.experimental.thin-launcher'
  103. springBoot {
  104. buildInfo()
  105. }
  106. // war {
  107. // manifest {
  108. // attributes("Implementation-Title": "Gradle")
  109. // }
  110. // }
  111. // task createPom {
  112. // doLast {
  113. // pom {
  114. // withXml(dependencyManagement.pomConfigurer)
  115. // }.writeTo("build/resources/main/META-INF/maven/${project.group}/${project.name}/pom.xml")
  116. // }
  117. // }
  118. //
  119. // thinResolvePrepare {
  120. // into new File("${buildDir}/thin/deploy")
  121. // }
  122. //
  123. // jar.dependsOn = [createPom]
  124. dependencies {
  125. // providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
  126. // providedRuntime 'org.springframework.boot:spring-boot-starter-jetty'
  127. }
  128. }
  129. project(':data') {
  130. dependencies {
  131. compile(project(":tools"))
  132. }
  133. }
  134. project(':gateway-api') {
  135. dependencies {
  136. compile(project(":tools"))
  137. compile(project(":data"))
  138. compileClasspath project(path:":tools", configuration: 'parentClasspath')
  139. compileClasspath project(path:":data", configuration: 'parentClasspath')
  140. }
  141. }