build.gradle 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. buildscript {
  2. repositories {
  3. maven { url "https://plugins.gradle.org/m2/" }
  4. }
  5. dependencies {
  6. classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10")
  7. classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
  8. }
  9. }
  10. ext {
  11. configuration = [
  12. javaVersion = JavaVersion.VERSION_1_8
  13. ]
  14. libraries = [
  15. mybatisSpringVersion = '1.3.2',
  16. mybatisVersion = '3.4.6',
  17. springVersion = '5.1.2.RELEASE',
  18. springBootVersion = '2.1.0.RELEASE',
  19. jsqlparserVersion = '1.3',
  20. ]
  21. dependencies = [
  22. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:1.3.10",
  23. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.10",
  24. "jsqlparser" : "com.github.jsqlparser:jsqlparser:${jsqlparserVersion}",
  25. "mybatis-spring" : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
  26. "mybatis" : "org.mybatis:mybatis:${mybatisVersion}",
  27. "spring-context-support" : "org.springframework:spring-context-support:${springVersion}",
  28. "spring-jdbc" : "org.springframework:spring-jdbc:${springVersion}",
  29. "spring-tx" : "org.springframework:spring-tx:${springVersion}",
  30. "spring-web" : "org.springframework:spring-web:${springVersion}",
  31. "spring-aop" : "org.springframework:spring-aop:${springVersion}",
  32. "cglib" : "cglib:cglib:3.2.6",
  33. "lombok" : "org.projectlombok:lombok:1.18.4",
  34. "javax.servlet-api" : "javax.servlet:javax.servlet-api:4.0.1",
  35. "aspectjweaver" : "org.aspectj:aspectjweaver:1.8.9",
  36. "mockito" : "org.mockito:mockito-core:2.13.0",
  37. "mybatis-ehcache" : "org.mybatis.caches:mybatis-ehcache:1.1.0",
  38. "slf4j-api" : "org.slf4j:slf4j-api:1.7.25",
  39. "logback-classic" : "ch.qos.logback:logback-classic:1.2.3",
  40. //test
  41. "spring-test" : "org.springframework:spring-test:${springVersion}",
  42. "junit" : "junit:junit:4.12",
  43. "mockito-all" : "org.mockito:mockito-all:1.10.19",
  44. "fastjson" : "com.alibaba:fastjson:1.2.49",
  45. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.9.6",
  46. "tomcatjdbc" : "org.apache.tomcat:tomcat-jdbc:9.0.2",
  47. //datasource
  48. "hikaricp" : "com.zaxxer:HikariCP:2.7.0",
  49. "druid" : "com.alibaba:druid:1.0.29",
  50. "commons-dbcp2" : "org.apache.commons:commons-dbcp2:2.1.1",
  51. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  52. "postgresql" : "org.postgresql:postgresql:9.4.1212",
  53. "oracle" : fileTree(dir: 'libs', includes: ['ojdbc-11.2.0.3-jdk16.jar']),
  54. "h2" : "com.h2database:h2:1.4.194",
  55. "mysql" : "mysql:mysql-connector-java:5.1.38",
  56. //code generator
  57. "velocity" : "org.apache.velocity:velocity-engine-core:2.0",
  58. "freemarker" : "org.freemarker:freemarker:2.3.9",
  59. // spring boot
  60. "springboot-autoconfigure" : "org.springframework.boot:spring-boot-autoconfigure:${springBootVersion}",
  61. "springboot-configuration-processor": "org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}",
  62. "springboot-starter-jdbc" : "org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}",
  63. ]
  64. }
  65. allprojects {
  66. group = 'com.baomidou'
  67. version = '3.0.7.4-SNAPSHOT'
  68. }
  69. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  70. subprojects {
  71. apply plugin: 'java'
  72. apply plugin: 'signing'
  73. apply plugin: 'maven-publish'
  74. apply plugin: 'nebula.optional-base'
  75. apply plugin: 'nebula.provided-base'
  76. sourceCompatibility = "${javaVersion}"
  77. targetCompatibility = "${javaVersion}"
  78. tasks.withType(JavaCompile) {
  79. options.encoding = 'UTF-8'
  80. }
  81. jar {
  82. manifest {
  83. attributes 'Implementation-Version': version
  84. }
  85. }
  86. repositories {
  87. mavenLocal()
  88. maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
  89. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  90. maven { url "http://www.cameliatk.jp/maven2/repository/thirdparty" }
  91. jcenter()
  92. }
  93. dependencies {
  94. provided rootProject.ext.dependencies["lombok"]
  95. testCompile rootProject.ext.dependencies["mockito-all"]
  96. testCompile rootProject.ext.dependencies["junit"]
  97. }
  98. task sourcesJar(type: Jar, dependsOn: classes) {
  99. classifier = 'sources'
  100. from sourceSets.main.allSource
  101. }
  102. javadoc {
  103. options {
  104. encoding "UTF-8"
  105. charSet 'UTF-8'
  106. author true
  107. version true
  108. failOnError false
  109. links "http://docs.oracle.com/javase/8/docs/api"
  110. }
  111. }
  112. task javadocJar(type: Jar, dependsOn: javadoc) {
  113. classifier = 'javadoc'
  114. from 'build/docs/javadoc'
  115. }
  116. artifacts {
  117. archives sourcesJar
  118. archives javadocJar
  119. }
  120. tasks.whenTaskAdded { task ->
  121. if (task.name.contains('signMavenJavaPublication')) {
  122. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  123. }
  124. }
  125. /*
  126. * 1.修改 gradle.properties 中 signing.secretKeyRingFile的路径
  127. * 2.执行 gradle clean build publish -Dun=用户名 -Dps=密码 -x test
  128. * ---------------------------wrapper------------------------------------------
  129. * 先执行 gradle wrapper 生成 gradlew 和 gradlew.bat
  130. * win: gradlew.bat clean build publish -Dun=用户名 -Dps=密码 -x test
  131. * mac: ./gradlew clean build publish -Dun=用户名 -Dps=密码 -x test
  132. */
  133. publishing {
  134. repositories {
  135. maven {
  136. def userName = System.getProperty("un")
  137. def passWord = System.getProperty("ps")
  138. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  139. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  140. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  141. credentials {
  142. username userName
  143. password passWord
  144. }
  145. }
  146. }
  147. publications {
  148. mavenJava(MavenPublication) {
  149. from components.java
  150. artifact sourcesJar
  151. artifact javadocJar
  152. pom {
  153. name = 'mybatis-plus'
  154. packaging 'jar'
  155. description = 'An enhanced toolkit of Mybatis to simplify development.'
  156. url = 'https://github.com/baomidou/mybatis-plus'
  157. scm {
  158. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  159. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  160. url = 'https://github.com/baomidou/mybatis-plus'
  161. }
  162. licenses {
  163. license {
  164. name = 'The Apache License, Version 2.0'
  165. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  166. }
  167. }
  168. developers {
  169. developer {
  170. id = 'baomidou'
  171. name = 'hubin'
  172. email = 'jobob@qq.com'
  173. }
  174. }
  175. withXml {
  176. asNode().dependencies.'*'.findAll() {
  177. it.scope.text() == 'compile' && project.configurations.provided.allDependencies.find { dep ->
  178. dep.name == it.artifactId.text()
  179. }
  180. }.each() {
  181. it.scope*.value = 'provided'
  182. }
  183. }
  184. }
  185. }
  186. }
  187. signing {
  188. sign publishing.publications.mavenJava
  189. }
  190. }
  191. }