build.gradle 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 fileTree(dir:'libs',include:['*.jar'])
  78. }
  79. //自定义环境 start
  80. def env = System.getProperty("ENV") ?: (System.getenv("ENV") ?: "dev")
  81. println(env)
  82. sourceSets {
  83. main {
  84. resources {
  85. srcDirs = ["src/main/resources", "src/main/profile/$env", "src/main/java"]
  86. }
  87. }
  88. }
  89. //自定义环境 end
  90. }
  91. // 如果不使用spring boot plugin,也可以使用spring boot dependency management,只需要导入SpringBootPlugin类的BOM_COORDINATES常量
  92. //dependencyManagement {
  93. // imports {
  94. // mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
  95. // }
  96. //}
  97. //如果module中名称有包含api的,则加入下面的内容
  98. configure(subprojects.findAll {it.name.contains('api')}) {
  99. apply plugin: 'war'
  100. apply plugin: 'application'
  101. // apply plugin: 'org.springframework.boot.experimental.thin-launcher'
  102. springBoot {
  103. buildInfo()
  104. }
  105. // war {
  106. // manifest {
  107. // attributes("Implementation-Title": "Gradle")
  108. // }
  109. // }
  110. // task createPom {
  111. // doLast {
  112. // pom {
  113. // withXml(dependencyManagement.pomConfigurer)
  114. // }.writeTo("build/resources/main/META-INF/maven/${project.group}/${project.name}/pom.xml")
  115. // }
  116. // }
  117. //
  118. // thinResolvePrepare {
  119. // into new File("${buildDir}/thin/deploy")
  120. // }
  121. //
  122. // jar.dependsOn = [createPom]
  123. dependencies {
  124. // providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
  125. // providedRuntime 'org.springframework.boot:spring-boot-starter-jetty'
  126. }
  127. }
  128. project(':data') {
  129. dependencies {
  130. compile(project(":tools"))
  131. }
  132. }
  133. project(':gateway-api') {
  134. dependencies {
  135. compile(project(":tools"))
  136. compile(project(":data"))
  137. compileClasspath project(path:":tools", configuration: 'parentClasspath')
  138. compileClasspath project(path:":data", configuration: 'parentClasspath')
  139. }
  140. }