build.gradle 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. import java.time.LocalDateTime
  2. allprojects {
  3. group APP_GROUP
  4. version APP_VERSION
  5. }
  6. ext {
  7. configuration = [
  8. javaVersion = JavaVersion.VERSION_21
  9. ]
  10. libraries = [
  11. mybatisVersion = '3.5.16',
  12. mybatisSpringVersion = '2.1.2',
  13. mybatisSpringBootStarterVersion = '2.3.2',
  14. springVersion = '5.3.37',
  15. springBootVersion = '2.7.18',
  16. springBoot3Version = '3.3.2',
  17. springCloudVersion = '3.1.8',
  18. jsqlparserVersion = '5.0',
  19. junitVersion = '5.11.0',
  20. ]
  21. lib = [
  22. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:2.0.10",
  23. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.10",
  24. "jsqlparser" : "com.github.jsqlparser:jsqlparser:${jsqlparserVersion}",
  25. "mybatis" : "org.mybatis:mybatis:${mybatisVersion}",
  26. "mybatis-spring" : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
  27. "mybatis-thymeleaf" : "org.mybatis.scripting:mybatis-thymeleaf:1.0.4",
  28. "mybatis-freemarker" : "org.mybatis.scripting:mybatis-freemarker:1.2.3",
  29. "mybatis-velocity" : "org.mybatis.scripting:mybatis-velocity:2.1.2",
  30. "spring-context-support" : "org.springframework:spring-context-support:${springVersion}",
  31. "spring-jdbc" : "org.springframework:spring-jdbc:${springVersion}",
  32. "spring-tx" : "org.springframework:spring-tx:${springVersion}",
  33. "spring-web" : "org.springframework:spring-web:${springVersion}",
  34. "spring-aop" : "org.springframework:spring-aop:${springVersion}",
  35. "cglib" : "cglib:cglib:3.3.0",
  36. "imadcn" : "com.imadcn.framework:idworker:1.6.0",
  37. "spring-cloud-commons" : "org.springframework.cloud:spring-cloud-commons:${springCloudVersion}",
  38. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.22.1",
  39. "slf4j-api" : "org.slf4j:slf4j-api:1.7.36",
  40. //copy
  41. "mybatis-spring-boot-starter": "org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisSpringBootStarterVersion}",
  42. //test
  43. "spring-test" : "org.springframework:spring-test:${springVersion}",
  44. "assertj-core" : "org.assertj:assertj-core:3.26.3",
  45. "junit-jupiter" : "org.junit.jupiter:junit-jupiter:${junitVersion}",
  46. "fastjson" : "com.alibaba:fastjson:2.0.52",
  47. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.17.2",
  48. "gson" : "com.google.code.gson:gson:2.11.0",
  49. "lagarto" : "org.jodd:jodd-lagarto:6.0.6",
  50. //datasource
  51. "p6spy" : "p6spy:p6spy:3.9.1",
  52. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  53. "postgresql" : "org.postgresql:postgresql:42.7.3",
  54. "oracle" : fileTree(dir: 'libs', includes: ['ojdbc8.jar']),
  55. "dm" : fileTree(dir: 'libs', includes: ["jdbcDriver-18.jar"]),
  56. "h2" : "com.h2database:h2:2.3.232",
  57. "mysql" : "com.mysql:mysql-connector-j:9.0.0",
  58. "sqlite" : "org.xerial:sqlite-jdbc:3.46.1.0",
  59. "firebird" : "org.firebirdsql.jdbc:jaybird:5.0.5.java8",
  60. //cache
  61. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.0.0",
  62. //code generator
  63. "velocity" : "org.apache.velocity:velocity-engine-core:2.3",
  64. "freemarker" : "org.freemarker:freemarker:2.3.33",
  65. "beetl" : "com.ibeetl:beetl:3.17.0.RELEASE",
  66. "swagger-annotations" : "io.swagger:swagger-annotations:1.6.14",
  67. "enjoy" : "com.jfinal:enjoy:5.1.3",
  68. "logback-classic" : "ch.qos.logback:logback-classic:1.5.7",
  69. ]
  70. }
  71. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  72. subprojects {
  73. apply plugin: 'java-library'
  74. apply plugin: 'signing'
  75. apply plugin: 'maven-publish'
  76. apply plugin: 'tech.yanand.maven-central-publish'
  77. apply plugin: "io.freefair.lombok"
  78. sourceCompatibility = "${javaVersion}"
  79. targetCompatibility = "${javaVersion}"
  80. lombok {
  81. version = "1.18.32"
  82. }
  83. compileJava {
  84. options.release = 8
  85. }
  86. repositories {
  87. mavenLocal()
  88. maven { url "https://maven.aliyun.com/repository/public" }
  89. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  90. mavenCentral()
  91. }
  92. dependencies {
  93. testImplementation "${lib["assertj-core"]}"
  94. testImplementation "${lib["junit-jupiter"]}"
  95. testImplementation "org.mockito:mockito-junit-jupiter:5.12.0"
  96. testImplementation "${lib["lagarto"]}"
  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. //noinspection GroovyAssignabilityCheck
  130. task sourcesJar(type: Jar) {
  131. archiveClassifier = 'sources'
  132. from sourceSets.main.allSource
  133. }
  134. javadoc {
  135. afterEvaluate {
  136. configure(options) {
  137. encoding "UTF-8"
  138. charSet 'UTF-8'
  139. author true
  140. version true
  141. failOnError false
  142. links "http://docs.oracle.com/javase/8/docs/api"
  143. }
  144. }
  145. }
  146. test {
  147. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  148. useJUnitPlatform()
  149. exclude("**/phoenix/**")
  150. exclude("**/postgresql/**")
  151. // exclude("**/generator/**")
  152. }
  153. task cleanBuildDir(type: Delete) {
  154. delete "${projectDir}/out"
  155. }
  156. tasks.clean.dependsOn(cleanBuildDir)
  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. name = "Local"
  170. url = layout.buildDirectory.dir('repos/bundles')
  171. }
  172. }
  173. // use example : ./gradlew clean build publish publishToMavenCentralPortal -DauthToken='xxxxxx' -x test
  174. mavenCentral {
  175. repoDir = layout.buildDirectory.dir('repos/bundles')
  176. // Base64 encoded of "username:password"
  177. authToken = System.getProperty("authToken")
  178. // 默认自动发布 AUTOMATIC
  179. publishingType = 'USER_MANAGED'
  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. }