build.gradle 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. import java.text.SimpleDateFormat
  2. buildscript {
  3. repositories {
  4. maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
  5. mavenCentral()
  6. maven { url "https://plugins.gradle.org/m2/" }
  7. }
  8. dependencies {
  9. //noinspection DifferentKotlinGradleVersion
  10. classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.30'
  11. classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.15.0"
  12. }
  13. }
  14. ext {
  15. configuration = [
  16. javaVersion = JavaVersion.VERSION_1_8
  17. ]
  18. libraries = [
  19. mybatisSpringVersion = '2.0.1',
  20. mybatisVersion = '3.5.1',
  21. springVersion = '5.1.6.RELEASE',
  22. springBootVersion = '2.1.4.RELEASE',
  23. jsqlparserVersion = '1.2',
  24. junitVersion = '5.4.0',
  25. ]
  26. lib = [
  27. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:1.3.10",
  28. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.10",
  29. "jsqlparser" : "com.github.jsqlparser:jsqlparser:${jsqlparserVersion}",
  30. "mybatis-spring" : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
  31. "mybatis" : "org.mybatis:mybatis:${mybatisVersion}",
  32. "spring-context-support": "org.springframework:spring-context-support:${springVersion}",
  33. "spring-jdbc" : "org.springframework:spring-jdbc:${springVersion}",
  34. "spring-tx" : "org.springframework:spring-tx:${springVersion}",
  35. "spring-web" : "org.springframework:spring-web:${springVersion}",
  36. "spring-aop" : "org.springframework:spring-aop:${springVersion}",
  37. "aspectjrt" : "org.aspectj:aspectjrt:1.8.13",
  38. "cglib" : "cglib:cglib:3.2.6",
  39. "lombok" : "org.projectlombok:lombok:1.18.4",
  40. "javax.servlet-api" : "javax.servlet:javax.servlet-api:4.0.1",
  41. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.2",
  42. "mockito" : "org.mockito:mockito-core:2.24.0",
  43. "mybatis-ehcache" : "org.mybatis.caches:mybatis-ehcache:1.1.0",
  44. "slf4j-api" : "org.slf4j:slf4j-api:1.7.25",
  45. "logback-classic" : "ch.qos.logback:logback-classic:1.2.3",
  46. //test
  47. "spring-test" : "org.springframework:spring-test:${springVersion}",
  48. "assertj-core" : "org.assertj:assertj-core:3.12.2",
  49. "junit-jupiter-api" : "org.junit.jupiter:junit-jupiter-api:${junitVersion}",
  50. "junit-jupiter-engine" : "org.junit.jupiter:junit-jupiter-engine:${junitVersion}",
  51. "mockito-all" : "org.mockito:mockito-all:1.10.19",
  52. "fastjson" : "com.alibaba:fastjson:1.2.56",
  53. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.9.6",
  54. "tomcatjdbc" : "org.apache.tomcat:tomcat-jdbc:9.0.16",
  55. "lagarto" : "org.jodd:jodd-lagarto:5.0.7",
  56. //datasource
  57. "hikaricp" : "com.zaxxer:HikariCP:3.3.0",
  58. "druid" : "com.alibaba:druid:1.0.29",
  59. "p6spy" : "p6spy:p6spy:3.8.1",
  60. "commons-dbcp2" : "org.apache.commons:commons-dbcp2:2.5.0",
  61. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  62. "postgresql" : "org.postgresql:postgresql:9.4.1212",
  63. "oracle" : fileTree(dir: 'libs', includes: ['ojdbc-11.2.0.3-jdk16.jar']),
  64. "h2" : "com.h2database:h2:1.4.197",
  65. "mysql" : "mysql:mysql-connector-java:8.0.15",
  66. "sqlite" : "org.xerial:sqlite-jdbc:3.27.2.1",
  67. //code generator
  68. "velocity" : "org.apache.velocity:velocity-engine-core:2.0",
  69. "freemarker" : "org.freemarker:freemarker:2.3.28",
  70. "beetl" : "com.ibeetl:beetl:2.9.8",
  71. "swagger-annotations" : "io.swagger:swagger-annotations:1.5.21"
  72. ]
  73. }
  74. allprojects {
  75. group = 'com.baomidou'
  76. version = "3.1.2.3-SNAPSHOT"
  77. }
  78. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  79. subprojects {
  80. apply plugin: 'java-library'
  81. apply plugin: 'signing'
  82. apply plugin: 'maven-publish'
  83. apply plugin: 'com.github.hierynomus.license'
  84. sourceCompatibility = "${javaVersion}"
  85. targetCompatibility = "${javaVersion}"
  86. tasks.withType(JavaCompile) {
  87. options.encoding = 'UTF-8'
  88. options.deprecation = true
  89. options.compilerArgs += ["-parameters"]
  90. }
  91. jar {
  92. afterEvaluate {
  93. manifest {
  94. attributes 'Implementation-Version': version
  95. attributes 'Built-Gradle': gradle.gradleVersion
  96. attributes 'Bundle-DocURL': 'https://mybatis.plus/'
  97. attributes 'Build-OS': System.getProperty("os.name")
  98. attributes 'Built-By': System.getProperty("user.name")
  99. attributes 'Build-Jdk': System.getProperty("java.version")
  100. attributes 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
  101. }
  102. }
  103. }
  104. license {
  105. encoding = "UTF-8"
  106. header = rootProject.file("license.txt")
  107. includes(["**/*.java", "**/*.kt"])
  108. exclude "**/*Test.java"
  109. exclude "**/TableNameParser.java"
  110. mapping "java", "SLASHSTAR_STYLE"
  111. mapping "kt", "SLASHSTAR_STYLE"
  112. }
  113. repositories {
  114. mavenLocal()
  115. maven { url "https://maven.aliyun.com/repository/public" }
  116. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  117. jcenter()
  118. }
  119. dependencies {
  120. annotationProcessor "${lib.lombok}"
  121. compileOnly "${lib.lombok}"
  122. testAnnotationProcessor "${lib.lombok}"
  123. testCompileOnly "${lib.lombok}"
  124. testImplementation("${lib["assertj-core"]}")
  125. testImplementation("${lib["junit-jupiter-api"]}")
  126. testRuntimeOnly("${lib["junit-jupiter-engine"]}")
  127. testCompileOnly("${lib["mockito-all"]}")
  128. testImplementation("org.mockito:mockito-junit-jupiter:2.24.0")
  129. testImplementation("${lib["lagarto"]}")
  130. }
  131. //noinspection GroovyAssignabilityCheck
  132. task sourcesJar(type: Jar) {
  133. archiveClassifier = 'sources'
  134. from sourceSets.main.allJava
  135. }
  136. javadoc {
  137. afterEvaluate {
  138. configure(options) {
  139. encoding "UTF-8"
  140. charSet 'UTF-8'
  141. author true
  142. version true
  143. failOnError false
  144. links "http://docs.oracle.com/javase/8/docs/api"
  145. }
  146. }
  147. }
  148. test {
  149. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  150. useJUnitPlatform()
  151. exclude("**/generator/**")
  152. exclude("**/postgres/**")
  153. exclude("**/mysql/**")
  154. }
  155. task javadocJar(type: Jar) {
  156. archiveClassifier = 'javadoc'
  157. from javadoc
  158. }
  159. tasks.whenTaskAdded { task ->
  160. if (task.name.contains('signMavenJavaPublication')) {
  161. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  162. }
  163. }
  164. publishing {
  165. repositories {
  166. maven {
  167. def userName = System.getProperty("un")
  168. def passWord = System.getProperty("ps")
  169. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  170. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  171. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  172. credentials {
  173. username userName
  174. password passWord
  175. }
  176. }
  177. }
  178. publications {
  179. mavenJava(MavenPublication) {
  180. from components.java
  181. artifact sourcesJar
  182. artifact javadocJar
  183. pom {
  184. name = 'mybatis-plus'
  185. packaging 'jar'
  186. description = 'An enhanced toolkit of Mybatis to simplify development.'
  187. url = 'https://github.com/baomidou/mybatis-plus'
  188. scm {
  189. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  190. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  191. url = 'https://github.com/baomidou/mybatis-plus'
  192. }
  193. licenses {
  194. license {
  195. name = 'The Apache License, Version 2.0'
  196. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  197. }
  198. }
  199. developers {
  200. developer {
  201. id = 'baomidou'
  202. name = 'hubin'
  203. email = 'jobob@qq.com'
  204. }
  205. }
  206. withXml {
  207. def root = asNode()
  208. root.dependencies.'*'.findAll {
  209. def d = it
  210. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  211. dep.name == it.artifactId.text()
  212. }.each() {
  213. d.scope*.value = 'compile'
  214. d.appendNode('optional', true)
  215. }
  216. }
  217. }
  218. }
  219. }
  220. }
  221. signing {
  222. sign publishing.publications.mavenJava
  223. }
  224. }
  225. }