build.gradle 11 KB

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