build.gradle 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import java.text.SimpleDateFormat
  2. allprojects {
  3. group = 'com.baomidou'
  4. version = "3.4.1"
  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 = '3.2',
  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. //code generator
  62. "velocity" : "org.apache.velocity:velocity-engine-core:2.2",
  63. "freemarker" : "org.freemarker:freemarker:2.3.30",
  64. "beetl" : "com.ibeetl:beetl:3.2.1.RELEASE",
  65. "swagger-annotations" : "io.swagger:swagger-annotations:1.6.2",
  66. //cache
  67. "mybatis-ehcache" : "org.mybatis.caches:mybatis-ehcache:1.2.1",
  68. "mybatis-redis" : "org.mybatis.caches:mybatis-redis:1.0.0-beta2",
  69. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.0.0-beta1"
  70. ]
  71. }
  72. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  73. subprojects {
  74. apply plugin: 'java-library'
  75. apply plugin: 'signing'
  76. apply plugin: 'maven-publish'
  77. apply plugin: "io.freefair.lombok"
  78. apply plugin: 'com.github.hierynomus.license'
  79. sourceCompatibility = "${javaVersion}"
  80. targetCompatibility = "${javaVersion}"
  81. repositories {
  82. mavenLocal()
  83. maven { url "https://maven.aliyun.com/repository/public" }
  84. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  85. jcenter()
  86. }
  87. dependencies {
  88. testImplementation "${lib["assertj-core"]}"
  89. testImplementation "${lib["junit-jupiter"]}"
  90. testImplementation "org.mockito:mockito-junit-jupiter:3.6.0"
  91. testImplementation "${lib["lagarto"]}"
  92. testImplementation "${lib["logback-classic"]}"
  93. }
  94. tasks.withType(JavaCompile) {
  95. options.encoding = 'UTF-8'
  96. options.warnings = false
  97. options.deprecation = true
  98. options.compilerArgs += ["-parameters"]
  99. }
  100. tasks.withType(GenerateModuleMetadata) {
  101. enabled = false
  102. }
  103. jar {
  104. afterEvaluate {
  105. manifest {
  106. attributes 'Implementation-Version': archiveVersion
  107. attributes 'Built-Gradle': gradle.gradleVersion
  108. attributes 'Bundle-DocURL': 'https://mybatis.plus/'
  109. attributes 'Build-OS': System.getProperty("os.name")
  110. attributes 'Built-By': System.getProperty("user.name")
  111. attributes 'Build-Jdk': System.getProperty("java.version")
  112. attributes 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
  113. }
  114. }
  115. }
  116. license {
  117. encoding = "UTF-8"
  118. header = rootProject.file("license.txt")
  119. includes(["**/*.java", "**/*.kt"])
  120. exclude "**/test/**/*.kt"
  121. exclude "**/test/**/*.java"
  122. exclude "**/*Test.java"
  123. exclude "**/TableNameParser.java"
  124. exclude "**/Maps.java"
  125. mapping "java", "SLASHSTAR_STYLE"
  126. mapping "kt", "SLASHSTAR_STYLE"
  127. ignoreFailures = true
  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("**/generator/**")
  150. exclude("**/mysql/**")
  151. exclude("**/phoenix/**")
  152. }
  153. task javadocJar(type: Jar) {
  154. archiveClassifier = 'javadoc'
  155. from javadoc
  156. }
  157. tasks.whenTaskAdded { task ->
  158. if (task.name.contains('signMavenJavaPublication')) {
  159. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  160. }
  161. }
  162. publishing {
  163. repositories {
  164. maven {
  165. def userName = System.getProperty("un")
  166. def passWord = System.getProperty("ps")
  167. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  168. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  169. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  170. credentials {
  171. username userName
  172. password passWord
  173. }
  174. }
  175. }
  176. publications {
  177. mavenJava(MavenPublication) {
  178. from components.java
  179. artifact sourcesJar
  180. artifact javadocJar
  181. pom {
  182. name = 'mybatis-plus'
  183. packaging 'jar'
  184. description = 'An enhanced toolkit of Mybatis to simplify development.'
  185. url = 'https://github.com/baomidou/mybatis-plus'
  186. scm {
  187. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  188. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  189. url = 'https://github.com/baomidou/mybatis-plus'
  190. }
  191. licenses {
  192. license {
  193. name = 'The Apache License, Version 2.0'
  194. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  195. }
  196. }
  197. developers {
  198. developer {
  199. id = 'baomidou'
  200. name = 'hubin'
  201. email = 'jobob@qq.com'
  202. }
  203. }
  204. withXml {
  205. def root = asNode()
  206. root.dependencies.'*'.findAll {
  207. def d = it
  208. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  209. dep.name == it.artifactId.text()
  210. }.each() {
  211. d.scope*.value = 'compile'
  212. d.appendNode('optional', true)
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. signing {
  220. sign publishing.publications.mavenJava
  221. }
  222. }
  223. }