build.gradle 10 KB

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