build.gradle 8.4 KB

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