build.gradle 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. import java.time.LocalDateTime
  2. allprojects {
  3. group = 'com.baomidou'
  4. version = "3.4.3.4"
  5. }
  6. ext {
  7. configuration = [
  8. javaVersion = JavaVersion.VERSION_1_8
  9. ]
  10. libraries = [
  11. mybatisVersion = '3.5.7',
  12. mybatisSpringVersion = '2.0.6',
  13. mybatisSpringBootStarterVersion = '2.2.0',
  14. springVersion = '5.3.9',
  15. springBootVersion = '2.5.3',
  16. jsqlparserVersion = '4.2',
  17. junitVersion = '5.7.2',
  18. ]
  19. lib = [
  20. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:1.3.72",
  21. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72",
  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.2",
  26. "mybatis-freemarker" : "org.mybatis.scripting:mybatis-freemarker:1.2.2",
  27. "mybatis-velocity" : "org.mybatis.scripting:mybatis-velocity:2.1.0",
  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.6",
  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.7",
  39. "slf4j-api" : "org.slf4j:slf4j-api:1.7.32",
  40. "logback-classic" : "ch.qos.logback:logback-classic:1.2.5",
  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.19.0",
  46. "junit-jupiter" : "org.junit.jupiter:junit-jupiter:${junitVersion}",
  47. "fastjson" : "com.alibaba:fastjson:1.2.76",
  48. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.12.5",
  49. "gson" : "com.google.code.gson:gson:2.8.8",
  50. "lagarto" : "org.jodd:jodd-lagarto:6.0.5",
  51. //datasource
  52. "p6spy" : "p6spy:p6spy:3.9.1",
  53. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  54. "postgresql" : "org.postgresql:postgresql:42.2.20",
  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:1.4.200",
  59. "mysql" : "mysql:mysql-connector-java:8.0.26",
  60. "sqlite" : "org.xerial:sqlite-jdbc:3.36.0.3",
  61. "firebird" : "org.firebirdsql.jdbc:jaybird:4.0.3.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. jcenter()
  82. }
  83. dependencies {
  84. testImplementation "${lib["assertj-core"]}"
  85. testImplementation "${lib["junit-jupiter"]}"
  86. testImplementation "org.mockito:mockito-junit-jupiter:3.12.4"
  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. }
  118. }
  119. }
  120. license {
  121. encoding = "UTF-8"
  122. header = rootProject.file("license.txt")
  123. includes(["**/*.java", "**/*.kt"])
  124. exclude "**/test/java/**/*.kt"
  125. exclude "**/test/java/**/*.java"
  126. exclude "**/*Test.java"
  127. mapping "java", "SLASHSTAR_STYLE"
  128. mapping "kt", "SLASHSTAR_STYLE"
  129. ignoreFailures = true
  130. ext.year = Calendar.getInstance().get(Calendar.YEAR)
  131. }
  132. //noinspection GroovyAssignabilityCheck
  133. task sourcesJar(type: Jar) {
  134. archiveClassifier = 'sources'
  135. from sourceSets.main.allSource
  136. }
  137. javadoc {
  138. afterEvaluate {
  139. configure(options) {
  140. encoding "UTF-8"
  141. charSet 'UTF-8'
  142. author true
  143. version true
  144. failOnError false
  145. links "http://docs.oracle.com/javase/8/docs/api"
  146. }
  147. }
  148. }
  149. test {
  150. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  151. useJUnitPlatform()
  152. exclude("**/mysql/**")
  153. exclude("**/phoenix/**")
  154. }
  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. def userName = System.getProperty("un")
  168. def passWord = System.getProperty("ps")
  169. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  170. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  171. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  172. credentials {
  173. username userName
  174. password passWord
  175. }
  176. }
  177. }
  178. publications {
  179. mavenJava(MavenPublication) {
  180. from components.java
  181. artifact sourcesJar
  182. artifact javadocJar
  183. pom {
  184. name = 'mybatis-plus'
  185. packaging 'jar'
  186. description = 'An enhanced toolkit of Mybatis to simplify development.'
  187. url = 'https://github.com/baomidou/mybatis-plus'
  188. scm {
  189. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  190. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  191. url = 'https://github.com/baomidou/mybatis-plus'
  192. }
  193. licenses {
  194. license {
  195. name = 'The Apache License, Version 2.0'
  196. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  197. }
  198. }
  199. developers {
  200. developer {
  201. id = 'baomidou'
  202. name = 'hubin'
  203. email = 'jobob@qq.com'
  204. }
  205. }
  206. withXml {
  207. def root = asNode()
  208. root.dependencies.'*'.findAll {
  209. def d = it
  210. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  211. dep.name == it.artifactId.text()
  212. }.each() {
  213. d.scope*.value = 'compile'
  214. d.appendNode('optional', true)
  215. }
  216. }
  217. }
  218. }
  219. }
  220. }
  221. signing {
  222. sign publishing.publications.mavenJava
  223. }
  224. }
  225. }