build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. //code generator
  68. // "mybatis-plus" : "com.baomidou:mybatis-plus:${mybatisPlusVersion}",
  69. "velocity" : "org.apache.velocity:velocity-engine-core:2.3",
  70. "freemarker" : "org.freemarker:freemarker:2.3.31",
  71. "beetl" : "com.ibeetl:beetl:3.7.0.RELEASE",
  72. "swagger-annotations" : "io.swagger:swagger-annotations:1.6.2",
  73. "enjoy" : "com.jfinal:enjoy:5.0.0",
  74. ]
  75. }
  76. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  77. subprojects {
  78. apply plugin: 'java-library'
  79. apply plugin: 'signing'
  80. apply plugin: 'maven-publish'
  81. apply plugin: "io.freefair.lombok"
  82. apply plugin: 'com.github.hierynomus.license'
  83. sourceCompatibility = "${javaVersion}"
  84. targetCompatibility = "${javaVersion}"
  85. repositories {
  86. mavenLocal()
  87. maven { url "https://maven.aliyun.com/repository/public" }
  88. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  89. mavenCentral()
  90. }
  91. dependencies {
  92. testImplementation "${lib["assertj-core"]}"
  93. testImplementation "${lib["junit-jupiter"]}"
  94. testImplementation "org.mockito:mockito-junit-jupiter:4.6.1"
  95. testImplementation "${lib["lagarto"]}"
  96. testImplementation "${lib["logback-classic"]}"
  97. }
  98. tasks.withType(JavaCompile) {
  99. options.encoding = 'UTF-8'
  100. options.warnings = false
  101. options.deprecation = true
  102. options.compilerArgs += ["-parameters"]
  103. }
  104. tasks.withType(GenerateModuleMetadata) {
  105. enabled = false
  106. }
  107. jar {
  108. into("META-INF/") {
  109. from rootProject.file("LICENSE")
  110. }
  111. into("META-INF/maven/$project.group/$project.name") {
  112. from { generatePomFileForMavenJavaPublication }
  113. rename ".*", "pom.xml"
  114. }
  115. afterEvaluate {
  116. manifest {
  117. attributes 'Implementation-Title': archiveBaseName
  118. attributes 'Implementation-Version': archiveVersion
  119. attributes 'Built-Gradle': gradle.gradleVersion
  120. attributes 'Bundle-DocURL': 'https://baomidou.com/'
  121. attributes 'Build-OS': System.getProperty("os.name")
  122. attributes 'Built-By': System.getProperty("user.name")
  123. attributes 'Build-Jdk': System.getProperty("java.version")
  124. attributes 'Build-Timestamp': LocalDateTime.now().format("yyyy-MM-dd HH:mm:ss")
  125. attributes 'Automatic-Module-Name': "${project.group}.${project.name.replaceAll("-", ".")}"
  126. }
  127. }
  128. }
  129. // 控制台直接执行 `gradle licenseMain` 或者 `gradle licenseFormatMain`
  130. // 前者是检查 main 源码的 licence 情况,后者是在 main 源码文件上 format license
  131. // 因为不打算在 test 代码上添加 licence, 所以不使用 licenseTest 和 licenseFormatTest 这俩
  132. license {
  133. encoding = "UTF-8"
  134. header = rootProject.file("license.txt")
  135. includes(["**/*.java", "**/*.kt"])
  136. mapping {
  137. java = "SLASHSTAR_STYLE"
  138. kt = "SLASHSTAR_STYLE"
  139. }
  140. ignoreFailures = true
  141. ext.year = Calendar.getInstance().get(Calendar.YEAR)
  142. }
  143. //noinspection GroovyAssignabilityCheck
  144. task sourcesJar(type: Jar) {
  145. archiveClassifier = 'sources'
  146. from sourceSets.main.allSource
  147. }
  148. javadoc {
  149. afterEvaluate {
  150. configure(options) {
  151. encoding "UTF-8"
  152. charSet 'UTF-8'
  153. author true
  154. version true
  155. failOnError false
  156. links "http://docs.oracle.com/javase/8/docs/api"
  157. }
  158. }
  159. }
  160. test {
  161. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  162. useJUnitPlatform()
  163. exclude("**/phoenix/**")
  164. }
  165. task javadocJar(type: Jar) {
  166. archiveClassifier = 'javadoc'
  167. from javadoc
  168. }
  169. tasks.whenTaskAdded { task ->
  170. if (task.name.contains('signMavenJavaPublication')) {
  171. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  172. }
  173. }
  174. publishing {
  175. repositories {
  176. maven {
  177. def userName = System.getProperty("un")
  178. def passWord = System.getProperty("ps")
  179. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  180. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  181. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  182. credentials {
  183. username userName
  184. password passWord
  185. }
  186. }
  187. }
  188. publications {
  189. mavenJava(MavenPublication) {
  190. from components.java
  191. artifact sourcesJar
  192. artifact javadocJar
  193. pom {
  194. name = 'mybatis-plus'
  195. packaging 'jar'
  196. description = 'An enhanced toolkit of Mybatis to simplify development.'
  197. url = 'https://github.com/baomidou/mybatis-plus'
  198. scm {
  199. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  200. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  201. url = 'https://github.com/baomidou/mybatis-plus'
  202. }
  203. licenses {
  204. license {
  205. name = 'The Apache License, Version 2.0'
  206. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  207. }
  208. }
  209. developers {
  210. developer {
  211. id = 'baomidou'
  212. name = 'hubin'
  213. email = 'jobob@qq.com'
  214. }
  215. }
  216. withXml {
  217. def root = asNode()
  218. root.dependencies.'*'.findAll {
  219. def d = it
  220. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  221. dep.name == it.artifactId.text()
  222. }.each() {
  223. d.scope*.value = 'compile'
  224. d.appendNode('optional', true)
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. signing {
  232. sign publishing.publications.mavenJava
  233. }
  234. }
  235. }