build.gradle 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. import java.time.LocalDateTime
  2. allprojects {
  3. group = 'com.baomidou'
  4. version = "3.4.1.2-SNAPSHOT"
  5. }
  6. ext {
  7. configuration = [
  8. javaVersion = JavaVersion.VERSION_1_8
  9. ]
  10. libraries = [
  11. mybatisVersion = '3.5.6',
  12. mybatisSpringVersion = '2.0.5',
  13. mybatisSpringBootStarterVersion = '2.1.3',
  14. springVersion = '5.2.8.RELEASE',
  15. springBootVersion = '2.3.2.RELEASE',
  16. jsqlparserVersion = '4.0',
  17. junitVersion = '5.7.0',
  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. "javax.servlet-api" : "javax.servlet:javax.servlet-api:4.0.1",
  37. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.6",
  38. "slf4j-api" : "org.slf4j:slf4j-api:1.7.30",
  39. "logback-classic" : "ch.qos.logback:logback-classic:1.2.3",
  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.18.0",
  45. "junit-jupiter" : "org.junit.jupiter:junit-jupiter:${junitVersion}",
  46. "fastjson" : "com.alibaba:fastjson:1.2.75",
  47. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.11.3",
  48. "gson" : "com.google.code.gson:gson:2.8.6",
  49. "lagarto" : "org.jodd:jodd-lagarto:6.0.2",
  50. //datasource
  51. "p6spy" : "p6spy:p6spy:3.9.1",
  52. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  53. "postgresql" : "org.postgresql:postgresql:42.2.14",
  54. "oracle" : fileTree(dir: 'libs', includes: ['ojdbc-11.2.0.3-jdk16.jar']),
  55. "dm" : fileTree(dir: 'libs', includes: ["jdbcDriver-18.jar"]),
  56. "kingbase" : fileTree(dir: 'libs', includes: ["kingbase8-8.2.0.jar"]),
  57. "h2" : "com.h2database:h2:1.4.200",
  58. "mysql" : "mysql:mysql-connector-java:8.0.21",
  59. "sqlite" : "org.xerial:sqlite-jdbc:3.32.3.1",
  60. "firebird" : "org.firebirdsql.jdbc:jaybird:4.0.1.java8",
  61. //cache
  62. "mybatis-ehcache" : "org.mybatis.caches:mybatis-ehcache:1.2.1",
  63. "mybatis-redis" : "org.mybatis.caches:mybatis-redis:1.0.0-beta2",
  64. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.0.0-beta1"
  65. ]
  66. }
  67. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  68. subprojects {
  69. apply plugin: 'java-library'
  70. apply plugin: 'signing'
  71. apply plugin: 'maven-publish'
  72. apply plugin: "io.freefair.lombok"
  73. apply plugin: 'com.github.hierynomus.license'
  74. sourceCompatibility = "${javaVersion}"
  75. targetCompatibility = "${javaVersion}"
  76. repositories {
  77. mavenLocal()
  78. maven { url "https://maven.aliyun.com/repository/public" }
  79. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  80. jcenter()
  81. }
  82. dependencies {
  83. testImplementation "${lib["assertj-core"]}"
  84. testImplementation "${lib["junit-jupiter"]}"
  85. testImplementation "org.mockito:mockito-junit-jupiter:3.6.0"
  86. testImplementation "${lib["lagarto"]}"
  87. testImplementation "${lib["logback-classic"]}"
  88. }
  89. tasks.withType(JavaCompile) {
  90. options.encoding = 'UTF-8'
  91. options.warnings = false
  92. options.deprecation = true
  93. options.compilerArgs += ["-parameters"]
  94. }
  95. tasks.withType(GenerateModuleMetadata) {
  96. enabled = false
  97. }
  98. jar {
  99. into("META-INF/") {
  100. from rootProject.file("LICENSE")
  101. }
  102. into("META-INF/maven/$project.group/$project.name") {
  103. from { generatePomFileForMavenJavaPublication }
  104. rename ".*", "pom.xml"
  105. }
  106. afterEvaluate {
  107. manifest {
  108. attributes 'Implementation-Title': archiveBaseName
  109. attributes 'Implementation-Version': archiveVersion
  110. attributes 'Built-Gradle': gradle.gradleVersion
  111. attributes 'Bundle-DocURL': 'https://mybatis.plus/'
  112. attributes 'Build-OS': System.getProperty("os.name")
  113. attributes 'Built-By': System.getProperty("user.name")
  114. attributes 'Build-Jdk': System.getProperty("java.version")
  115. attributes 'Build-Timestamp': LocalDateTime.now().format("yyyy-MM-dd HH:mm:ss")
  116. }
  117. }
  118. }
  119. license {
  120. encoding = "UTF-8"
  121. header = rootProject.file("license.txt")
  122. includes(["**/*.java", "**/*.kt"])
  123. exclude "**/test/java/**/*.kt"
  124. exclude "**/test/java/**/*.java"
  125. exclude "**/*Test.java"
  126. mapping "java", "SLASHSTAR_STYLE"
  127. mapping "kt", "SLASHSTAR_STYLE"
  128. ignoreFailures = true
  129. ext.year = Calendar.getInstance().get(Calendar.YEAR)
  130. }
  131. //noinspection GroovyAssignabilityCheck
  132. task sourcesJar(type: Jar) {
  133. archiveClassifier = 'sources'
  134. from sourceSets.main.allSource
  135. }
  136. javadoc {
  137. afterEvaluate {
  138. configure(options) {
  139. encoding "UTF-8"
  140. charSet 'UTF-8'
  141. author true
  142. version true
  143. failOnError false
  144. links "http://docs.oracle.com/javase/8/docs/api"
  145. }
  146. }
  147. }
  148. test {
  149. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  150. useJUnitPlatform()
  151. exclude("**/mysql/**")
  152. exclude("**/phoenix/**")
  153. }
  154. task javadocJar(type: Jar) {
  155. archiveClassifier = 'javadoc'
  156. from javadoc
  157. }
  158. tasks.whenTaskAdded { task ->
  159. if (task.name.contains('signMavenJavaPublication')) {
  160. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  161. }
  162. }
  163. publishing {
  164. repositories {
  165. maven {
  166. def userName = System.getProperty("un")
  167. def passWord = System.getProperty("ps")
  168. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  169. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  170. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  171. credentials {
  172. username userName
  173. password passWord
  174. }
  175. }
  176. }
  177. publications {
  178. mavenJava(MavenPublication) {
  179. from components.java
  180. artifact sourcesJar
  181. artifact javadocJar
  182. pom {
  183. name = 'mybatis-plus'
  184. packaging 'jar'
  185. description = 'An enhanced toolkit of Mybatis to simplify development.'
  186. url = 'https://github.com/baomidou/mybatis-plus'
  187. scm {
  188. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  189. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  190. url = 'https://github.com/baomidou/mybatis-plus'
  191. }
  192. licenses {
  193. license {
  194. name = 'The Apache License, Version 2.0'
  195. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  196. }
  197. }
  198. developers {
  199. developer {
  200. id = 'baomidou'
  201. name = 'hubin'
  202. email = 'jobob@qq.com'
  203. }
  204. }
  205. withXml {
  206. def root = asNode()
  207. root.dependencies.'*'.findAll {
  208. def d = it
  209. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  210. dep.name == it.artifactId.text()
  211. }.each() {
  212. d.scope*.value = 'compile'
  213. d.appendNode('optional', true)
  214. }
  215. }
  216. }
  217. }
  218. }
  219. }
  220. signing {
  221. sign publishing.publications.mavenJava
  222. }
  223. }
  224. }