build.gradle 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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.19',
  12. mybatisSpringVersion = '2.1.2',
  13. mybatisSpringBootStarterVersion = '2.3.2',
  14. springVersion = '5.3.39',
  15. springBootVersion = '2.7.18',
  16. springBoot3Version = '3.4.1',
  17. springCloudVersion = '3.1.8',
  18. junitVersion = '5.11.0',
  19. ]
  20. lib = [
  21. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:2.1.0",
  22. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0",
  23. "mybatis" : "org.mybatis:mybatis:${mybatisVersion}",
  24. "mybatis-spring" : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
  25. "mybatis-thymeleaf" : "org.mybatis.scripting:mybatis-thymeleaf:1.0.4",
  26. "mybatis-freemarker" : "org.mybatis.scripting:mybatis-freemarker:1.3.0",
  27. "mybatis-velocity" : "org.mybatis.scripting:mybatis-velocity:2.1.2",
  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. "cglib" : "cglib:cglib:3.3.0",
  34. "imadcn" : "com.imadcn.framework:idworker:1.6.0",
  35. "spring-cloud-commons" : "org.springframework.cloud:spring-cloud-commons:${springCloudVersion}",
  36. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.22.1",
  37. "slf4j-api" : "org.slf4j:slf4j-api:1.7.36",
  38. //copy
  39. "mybatis-spring-boot-starter": "org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisSpringBootStarterVersion}",
  40. //test
  41. "spring-test" : "org.springframework:spring-test:${springVersion}",
  42. "assertj-core" : "org.assertj:assertj-core:3.26.3",
  43. "junit-jupiter" : "org.junit.jupiter:junit-jupiter:${junitVersion}",
  44. "fastjson" : "com.alibaba:fastjson:2.0.53",
  45. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.17.3",
  46. "gson" : "com.google.code.gson:gson:2.11.0",
  47. "lagarto" : "org.jodd:jodd-lagarto:6.0.6",
  48. //datasource
  49. "p6spy" : "p6spy:p6spy:3.9.1",
  50. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  51. "postgresql" : "org.postgresql:postgresql:42.7.4",
  52. "oracle" : "com.oracle.database.jdbc:ojdbc8:23.7.0.25.01",
  53. "dm" : fileTree(dir: 'libs', includes: ["jdbcDriver-18.jar"]),
  54. "h2" : "com.h2database:h2:2.3.232",
  55. "mysql" : "com.mysql:mysql-connector-j:9.0.0",
  56. "sqlite" : "org.xerial:sqlite-jdbc:3.46.1.0",
  57. "firebird" : "org.firebirdsql.jdbc:jaybird:5.0.5.java8",
  58. //cache
  59. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.2.0",
  60. //code generator
  61. "velocity" : "org.apache.velocity:velocity-engine-core:2.4.1",
  62. "freemarker" : "org.freemarker:freemarker:2.3.33",
  63. "beetl" : "com.ibeetl:beetl:3.17.0.RELEASE",
  64. "swagger-annotations" : "io.swagger:swagger-annotations:1.6.14",
  65. "enjoy" : "com.jfinal:enjoy:5.2.2",
  66. "logback-classic" : "ch.qos.logback:logback-classic:1.5.15",
  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: 'tech.yanand.maven-central-publish'
  75. apply plugin: "io.freefair.lombok"
  76. sourceCompatibility = "${javaVersion}"
  77. targetCompatibility = "${javaVersion}"
  78. lombok {
  79. version = "1.18.32"
  80. }
  81. compileJava {
  82. options.release = 8
  83. }
  84. repositories {
  85. mavenLocal()
  86. maven { url "https://maven.aliyun.com/repository/public" }
  87. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  88. mavenCentral()
  89. }
  90. dependencies {
  91. testImplementation "${lib["assertj-core"]}"
  92. testImplementation "${lib["junit-jupiter"]}"
  93. testImplementation "org.mockito:mockito-junit-jupiter:5.13.0"
  94. testImplementation "${lib["lagarto"]}"
  95. }
  96. tasks.withType(JavaCompile) {
  97. options.encoding = 'UTF-8'
  98. options.warnings = false
  99. options.deprecation = true
  100. options.compilerArgs += ["-parameters"]
  101. }
  102. tasks.withType(GenerateModuleMetadata) {
  103. enabled = false
  104. }
  105. jar {
  106. into("META-INF/") {
  107. from rootProject.file("LICENSE")
  108. }
  109. into("META-INF/maven/$project.group/$project.name") {
  110. from { generatePomFileForMavenJavaPublication }
  111. rename ".*", "pom.xml"
  112. }
  113. afterEvaluate {
  114. manifest {
  115. attributes 'Implementation-Title': archiveBaseName
  116. attributes 'Implementation-Version': archiveVersion
  117. attributes 'Built-Gradle': gradle.gradleVersion
  118. attributes 'Bundle-DocURL': 'https://baomidou.com/'
  119. attributes 'Build-OS': System.getProperty("os.name")
  120. attributes 'Built-By': System.getProperty("user.name")
  121. attributes 'Build-Jdk': System.getProperty("java.version")
  122. attributes 'Build-Timestamp': LocalDateTime.now().format("yyyy-MM-dd HH:mm:ss")
  123. attributes 'Automatic-Module-Name': "${project.group}.${project.name.replaceAll("-", ".")}"
  124. }
  125. }
  126. }
  127. //noinspection GroovyAssignabilityCheck
  128. task sourcesJar(type: Jar) {
  129. archiveClassifier = 'sources'
  130. from sourceSets.main.allSource
  131. }
  132. javadoc {
  133. afterEvaluate {
  134. configure(options) {
  135. encoding "UTF-8"
  136. charSet 'UTF-8'
  137. author true
  138. version true
  139. failOnError false
  140. links "http://docs.oracle.com/javase/8/docs/api"
  141. }
  142. }
  143. }
  144. test {
  145. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  146. useJUnitPlatform()
  147. exclude("**/phoenix/**")
  148. exclude("**/postgresql/**")
  149. // exclude("**/generator/**")
  150. }
  151. task cleanBuildDir(type: Delete) {
  152. delete "${projectDir}/out"
  153. }
  154. tasks.clean.dependsOn(cleanBuildDir)
  155. task javadocJar(type: Jar) {
  156. archiveClassifier = 'javadoc'
  157. from javadoc
  158. }
  159. tasks.whenTaskAdded { task ->
  160. if (task.name.contains('signMavenJavaPublication')) {
  161. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  162. }
  163. }
  164. publishing {
  165. repositories {
  166. maven {
  167. name = "Local"
  168. url = layout.buildDirectory.dir('repos/bundles')
  169. }
  170. maven {
  171. def userName = System.getProperty("un")
  172. def passWord = System.getProperty("ps")
  173. name = "snapshots"
  174. url = "https://central.sonatype.com/repository/maven-snapshots/"
  175. credentials {
  176. username userName
  177. password passWord
  178. }
  179. }
  180. }
  181. // use example : ./gradlew clean build publishMavenJavaPublicationToLocalRepository publishToMavenCentralPortal -DauthToken='xxxxxx' -x test
  182. mavenCentral {
  183. repoDir = layout.buildDirectory.dir('repos/bundles')
  184. // Base64 encoded of "username:password"
  185. authToken = System.getProperty("authToken")
  186. // 默认自动发布 AUTOMATIC
  187. publishingType = 'USER_MANAGED'
  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. }