build.gradle 4.9 KB

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