build.gradle 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. import java.time.LocalDateTime
  2. allprojects {
  3. group = 'com.baomidou'
  4. version = "3.5.2.6-SNAPSHOT"
  5. }
  6. ext {
  7. configuration = [
  8. javaVersion = JavaVersion.VERSION_1_8
  9. ]
  10. libraries = [
  11. mybatisVersion = '3.5.10',
  12. mybatisSpringVersion = '2.0.7',
  13. mybatisSpringBootStarterVersion = '2.2.2',
  14. springVersion = '5.3.15',
  15. springBootVersion = '2.5.3',
  16. jsqlparserVersion = '4.4', // 4.5 有bug
  17. junitVersion = '5.9.0',
  18. ]
  19. lib = [
  20. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:1.7.10",
  21. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10",
  22. "jsqlparser" : "com.github.jsqlparser:jsqlparser:${jsqlparserVersion}",
  23. "mybatis" : "org.mybatis:mybatis:${mybatisVersion}",
  24. "mybatis-spring" : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
  25. "mybatis-thymeleaf" : "org.mybatis.scripting:mybatis-thymeleaf:1.0.3",
  26. "mybatis-freemarker" : "org.mybatis.scripting:mybatis-freemarker:1.2.3",
  27. "mybatis-velocity" : "org.mybatis.scripting:mybatis-velocity:2.1.1",
  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. "aspectjrt" : "org.aspectj:aspectjrt:1.9.9.1",
  34. "cglib" : "cglib:cglib:3.3.0",
  35. "imadcn" : "com.imadcn.framework:idworker:1.5.0",
  36. "spring-cloud-commons" : "org.springframework.cloud:spring-cloud-commons:3.0.3",
  37. "javax.servlet-api" : "javax.servlet:javax.servlet-api:4.0.1",
  38. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.9.1",
  39. "slf4j-api" : "org.slf4j:slf4j-api:1.7.36",
  40. "logback-classic" : "ch.qos.logback:logback-classic:1.2.11",
  41. //copy
  42. "mybatis-spring-boot-starter": "org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisSpringBootStarterVersion}",
  43. //test
  44. "spring-test" : "org.springframework:spring-test:${springVersion}",
  45. "assertj-core" : "org.assertj:assertj-core:3.23.1",
  46. "junit-jupiter" : "org.junit.jupiter:junit-jupiter:${junitVersion}",
  47. "fastjson" : "com.alibaba:fastjson:2.0.11",
  48. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.13.3",
  49. "gson" : "com.google.code.gson:gson:2.9.1",
  50. "lagarto" : "org.jodd:jodd-lagarto:6.0.6",
  51. //datasource
  52. "p6spy" : "p6spy:p6spy:3.9.1",
  53. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  54. "postgresql" : "org.postgresql:postgresql:42.4.1",
  55. "oracle" : fileTree(dir: 'libs', includes: ['ojdbc-11.2.0.3-jdk16.jar']),
  56. "dm" : fileTree(dir: 'libs', includes: ["jdbcDriver-18.jar"]),
  57. "kingbase" : fileTree(dir: 'libs', includes: ["kingbase8-8.2.0.jar"]),
  58. "h2" : "com.h2database:h2:2.1.214",
  59. "mysql" : "mysql:mysql-connector-java:8.0.30",
  60. "sqlite" : "org.xerial:sqlite-jdbc:3.39.2.0",
  61. "firebird" : "org.firebirdsql.jdbc:jaybird:4.0.6.java8",
  62. //cache
  63. "mybatis-ehcache" : "org.mybatis.caches:mybatis-ehcache:1.2.1",
  64. "mybatis-redis" : "org.mybatis.caches:mybatis-redis:1.0.0-beta2",
  65. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.0.0"
  66. ]
  67. }
  68. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  69. subprojects {
  70. apply plugin: 'java-library'
  71. apply plugin: 'signing'
  72. apply plugin: 'maven-publish'
  73. apply plugin: "io.freefair.lombok"
  74. apply plugin: 'com.github.hierynomus.license'
  75. sourceCompatibility = "${javaVersion}"
  76. targetCompatibility = "${javaVersion}"
  77. repositories {
  78. mavenLocal()
  79. maven { url "https://maven.aliyun.com/repository/public" }
  80. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  81. mavenCentral()
  82. }
  83. dependencies {
  84. testImplementation "${lib["assertj-core"]}"
  85. testImplementation "${lib["junit-jupiter"]}"
  86. testImplementation "org.mockito:mockito-junit-jupiter:4.6.1"
  87. testImplementation "${lib["lagarto"]}"
  88. testImplementation "${lib["logback-classic"]}"
  89. }
  90. tasks.withType(JavaCompile) {
  91. options.encoding = 'UTF-8'
  92. options.warnings = false
  93. options.deprecation = true
  94. options.compilerArgs += ["-parameters"]
  95. }
  96. tasks.withType(GenerateModuleMetadata) {
  97. enabled = false
  98. }
  99. jar {
  100. into("META-INF/") {
  101. from rootProject.file("LICENSE")
  102. }
  103. into("META-INF/maven/$project.group/$project.name") {
  104. from { generatePomFileForMavenJavaPublication }
  105. rename ".*", "pom.xml"
  106. }
  107. afterEvaluate {
  108. manifest {
  109. attributes 'Implementation-Title': archiveBaseName
  110. attributes 'Implementation-Version': archiveVersion
  111. attributes 'Built-Gradle': gradle.gradleVersion
  112. attributes 'Bundle-DocURL': 'https://baomidou.com/'
  113. attributes 'Build-OS': System.getProperty("os.name")
  114. attributes 'Built-By': System.getProperty("user.name")
  115. attributes 'Build-Jdk': System.getProperty("java.version")
  116. attributes 'Build-Timestamp': LocalDateTime.now().format("yyyy-MM-dd HH:mm:ss")
  117. attributes 'Automatic-Module-Name': "${project.group}.${project.name.replaceAll("-", ".")}"
  118. }
  119. }
  120. }
  121. // 控制台直接执行 `gradle licenseMain` 或者 `gradle licenseFormatMain`
  122. // 前者是检查 main 源码的 licence 情况,后者是在 main 源码文件上 format license
  123. // 因为不打算在 test 代码上添加 licence, 所以不使用 licenseTest 和 licenseFormatTest 这俩
  124. license {
  125. encoding = "UTF-8"
  126. header = rootProject.file("license.txt")
  127. includes(["**/*.java", "**/*.kt"])
  128. mapping {
  129. java = "SLASHSTAR_STYLE"
  130. kt = "SLASHSTAR_STYLE"
  131. }
  132. ignoreFailures = true
  133. ext.year = Calendar.getInstance().get(Calendar.YEAR)
  134. }
  135. //noinspection GroovyAssignabilityCheck
  136. task sourcesJar(type: Jar) {
  137. archiveClassifier = 'sources'
  138. from sourceSets.main.allSource
  139. }
  140. javadoc {
  141. afterEvaluate {
  142. configure(options) {
  143. encoding "UTF-8"
  144. charSet 'UTF-8'
  145. author true
  146. version true
  147. failOnError false
  148. links "http://docs.oracle.com/javase/8/docs/api"
  149. }
  150. }
  151. }
  152. test {
  153. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  154. useJUnitPlatform()
  155. exclude("**/phoenix/**")
  156. }
  157. task javadocJar(type: Jar) {
  158. archiveClassifier = 'javadoc'
  159. from javadoc
  160. }
  161. tasks.whenTaskAdded { task ->
  162. if (task.name.contains('signMavenJavaPublication')) {
  163. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  164. }
  165. }
  166. publishing {
  167. repositories {
  168. maven {
  169. def userName = System.getProperty("un")
  170. def passWord = System.getProperty("ps")
  171. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  172. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  173. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  174. credentials {
  175. username userName
  176. password passWord
  177. }
  178. }
  179. }
  180. publications {
  181. mavenJava(MavenPublication) {
  182. from components.java
  183. artifact sourcesJar
  184. artifact javadocJar
  185. pom {
  186. name = 'mybatis-plus'
  187. packaging 'jar'
  188. description = 'An enhanced toolkit of Mybatis to simplify development.'
  189. url = 'https://github.com/baomidou/mybatis-plus'
  190. scm {
  191. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  192. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  193. url = 'https://github.com/baomidou/mybatis-plus'
  194. }
  195. licenses {
  196. license {
  197. name = 'The Apache License, Version 2.0'
  198. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  199. }
  200. }
  201. developers {
  202. developer {
  203. id = 'baomidou'
  204. name = 'hubin'
  205. email = 'jobob@qq.com'
  206. }
  207. }
  208. withXml {
  209. def root = asNode()
  210. root.dependencies.'*'.findAll {
  211. def d = it
  212. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  213. dep.name == it.artifactId.text()
  214. }.each() {
  215. d.scope*.value = 'compile'
  216. d.appendNode('optional', true)
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. signing {
  224. sign publishing.publications.mavenJava
  225. }
  226. }
  227. }