build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import java.text.SimpleDateFormat
  2. buildscript {
  3. repositories {
  4. maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
  5. maven { url "https://maven.aliyun.com/nexus/content/repositories/gradle-plugin" }
  6. mavenCentral()
  7. maven { url "https://plugins.gradle.org/m2/" }
  8. }
  9. dependencies {
  10. //noinspection DifferentKotlinGradleVersion
  11. classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72'
  12. classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.15.0"
  13. }
  14. }
  15. ext {
  16. configuration = [
  17. javaVersion = JavaVersion.VERSION_1_8
  18. ]
  19. libraries = [
  20. mybatisVersion = '3.5.5',
  21. mybatisSpringVersion = '2.0.5',
  22. mybatisSpringBootStarterVersion = '2.1.3',
  23. springVersion = '5.2.8.RELEASE',
  24. springBootVersion = '2.3.2.RELEASE',
  25. jsqlparserVersion = '3.2',
  26. junitVersion = '5.6.2',
  27. ]
  28. lib = [
  29. "kotlin-reflect" : "org.jetbrains.kotlin:kotlin-reflect:1.3.72",
  30. "kotlin-stdlib-jdk8" : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72",
  31. "jsqlparser" : "com.github.jsqlparser:jsqlparser:${jsqlparserVersion}",
  32. "mybatis" : "org.mybatis:mybatis:${mybatisVersion}",
  33. "mybatis-spring" : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
  34. "mybatis-thymeleaf" : "org.mybatis.scripting:mybatis-thymeleaf:1.0.2",
  35. "mybatis-freemarker" : "org.mybatis.scripting:mybatis-freemarker:1.2.2",
  36. "mybatis-velocity" : "org.mybatis.scripting:mybatis-velocity:2.1.0",
  37. "spring-context-support" : "org.springframework:spring-context-support:${springVersion}",
  38. "spring-jdbc" : "org.springframework:spring-jdbc:${springVersion}",
  39. "spring-tx" : "org.springframework:spring-tx:${springVersion}",
  40. "spring-web" : "org.springframework:spring-web:${springVersion}",
  41. "spring-aop" : "org.springframework:spring-aop:${springVersion}",
  42. "aspectjrt" : "org.aspectj:aspectjrt:1.9.6",
  43. "cglib" : "cglib:cglib:3.3.0",
  44. "lombok" : "org.projectlombok:lombok:1.18.12",
  45. "imadcn" : "com.imadcn.framework:idworker:1.5.0",
  46. "javax.servlet-api" : "javax.servlet:javax.servlet-api:4.0.1",
  47. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.6",
  48. "slf4j-api" : "org.slf4j:slf4j-api:1.7.30",
  49. "logback-classic" : "ch.qos.logback:logback-classic:1.2.3",
  50. //copy
  51. "mybatis-spring-boot-starter": "org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisSpringBootStarterVersion}",
  52. //test
  53. "spring-test" : "org.springframework:spring-test:${springVersion}",
  54. "assertj-core" : "org.assertj:assertj-core:3.16.1",
  55. "junit-jupiter-api" : "org.junit.jupiter:junit-jupiter-api:${junitVersion}",
  56. "junit-jupiter-engine" : "org.junit.jupiter:junit-jupiter-engine:${junitVersion}",
  57. "fastjson" : "com.alibaba:fastjson:1.2.73",
  58. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.11.1",
  59. "gson" : "com.google.code.gson:gson:2.8.6",
  60. "lagarto" : "org.jodd:jodd-lagarto:5.1.5",
  61. //datasource
  62. "p6spy" : "p6spy:p6spy:3.9.1",
  63. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  64. "postgresql" : "org.postgresql:postgresql:42.2.14",
  65. "oracle" : fileTree(dir: 'libs', includes: ['ojdbc-11.2.0.3-jdk16.jar']),
  66. "dm" : fileTree(dir: 'libs', includes: ["jdbcDriver-18.jar"]),
  67. "kingbase" : fileTree(dir: 'libs', includes: ["kingbase8-8.2.0.jar"]),
  68. "h2" : "com.h2database:h2:1.4.200",
  69. "mysql" : "mysql:mysql-connector-java:8.0.21",
  70. "sqlite" : "org.xerial:sqlite-jdbc:3.32.3.1",
  71. "firebird" : "org.firebirdsql.jdbc:jaybird:4.0.1.java8",
  72. //code generator
  73. "velocity" : "org.apache.velocity:velocity-engine-core:2.2",
  74. "freemarker" : "org.freemarker:freemarker:2.3.30",
  75. "beetl" : "com.ibeetl:beetl:3.1.8.RELEASE",
  76. "swagger-annotations" : "io.swagger:swagger-annotations:1.6.2",
  77. //cache
  78. "mybatis-ehcache" : "org.mybatis.caches:mybatis-ehcache:1.2.1",
  79. "mybatis-redis" : "org.mybatis.caches:mybatis-redis:1.0.0-beta2",
  80. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.0.0-beta1"
  81. ]
  82. }
  83. allprojects {
  84. group = 'com.baomidou'
  85. version = "3.4.0.2-SNAPSHOT"
  86. }
  87. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  88. subprojects {
  89. apply plugin: 'java-library'
  90. apply plugin: 'signing'
  91. apply plugin: 'maven-publish'
  92. apply plugin: 'com.github.hierynomus.license'
  93. sourceCompatibility = "${javaVersion}"
  94. targetCompatibility = "${javaVersion}"
  95. tasks.withType(JavaCompile) {
  96. options.encoding = 'UTF-8'
  97. options.warnings = false
  98. options.deprecation = true
  99. options.compilerArgs += ["-parameters"]
  100. }
  101. tasks.withType(GenerateModuleMetadata) {
  102. enabled = false
  103. }
  104. jar {
  105. afterEvaluate {
  106. manifest {
  107. attributes 'Implementation-Version': archiveVersion
  108. attributes 'Built-Gradle': gradle.gradleVersion
  109. attributes 'Bundle-DocURL': 'https://mybatis.plus/'
  110. attributes 'Build-OS': System.getProperty("os.name")
  111. attributes 'Built-By': System.getProperty("user.name")
  112. attributes 'Build-Jdk': System.getProperty("java.version")
  113. attributes 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
  114. }
  115. }
  116. }
  117. license {
  118. encoding = "UTF-8"
  119. header = rootProject.file("license.txt")
  120. includes(["**/*.java", "**/*.kt"])
  121. exclude "**/test/**/*.kt"
  122. exclude "**/test/**/*.java"
  123. exclude "**/*Test.java"
  124. exclude "**/TableNameParser.java"
  125. exclude "**/Maps.java"
  126. mapping "java", "SLASHSTAR_STYLE"
  127. mapping "kt", "SLASHSTAR_STYLE"
  128. ignoreFailures = true
  129. }
  130. repositories {
  131. mavenLocal()
  132. maven { url "https://maven.aliyun.com/repository/public" }
  133. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  134. jcenter()
  135. }
  136. dependencies {
  137. annotationProcessor "${lib.lombok}"
  138. compileOnly "${lib.lombok}"
  139. testAnnotationProcessor "${lib.lombok}"
  140. testCompileOnly "${lib.lombok}"
  141. testImplementation "${lib["assertj-core"]}"
  142. testImplementation "${lib["junit-jupiter-api"]}"
  143. testRuntimeOnly "${lib["junit-jupiter-engine"]}"
  144. testImplementation "org.mockito:mockito-junit-jupiter:3.4.4"
  145. testImplementation "${lib["lagarto"]}"
  146. testImplementation "${lib["logback-classic"]}"
  147. }
  148. //noinspection GroovyAssignabilityCheck
  149. task sourcesJar(type: Jar) {
  150. archiveClassifier = 'sources'
  151. from sourceSets.main.allSource
  152. }
  153. javadoc {
  154. afterEvaluate {
  155. configure(options) {
  156. encoding "UTF-8"
  157. charSet 'UTF-8'
  158. author true
  159. version true
  160. failOnError false
  161. links "http://docs.oracle.com/javase/8/docs/api"
  162. }
  163. }
  164. }
  165. test {
  166. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  167. useJUnitPlatform()
  168. exclude("**/generator/**")
  169. exclude("**/mysql/**")
  170. exclude("**/phoenix/**")
  171. }
  172. task javadocJar(type: Jar) {
  173. archiveClassifier = 'javadoc'
  174. from javadoc
  175. }
  176. tasks.whenTaskAdded { task ->
  177. if (task.name.contains('signMavenJavaPublication')) {
  178. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  179. }
  180. }
  181. publishing {
  182. repositories {
  183. maven {
  184. def userName = System.getProperty("un")
  185. def passWord = System.getProperty("ps")
  186. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  187. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  188. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  189. credentials {
  190. username userName
  191. password passWord
  192. }
  193. }
  194. }
  195. publications {
  196. mavenJava(MavenPublication) {
  197. from components.java
  198. artifact sourcesJar
  199. artifact javadocJar
  200. pom {
  201. name = 'mybatis-plus'
  202. packaging 'jar'
  203. description = 'An enhanced toolkit of Mybatis to simplify development.'
  204. url = 'https://github.com/baomidou/mybatis-plus'
  205. scm {
  206. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  207. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  208. url = 'https://github.com/baomidou/mybatis-plus'
  209. }
  210. licenses {
  211. license {
  212. name = 'The Apache License, Version 2.0'
  213. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  214. }
  215. }
  216. developers {
  217. developer {
  218. id = 'baomidou'
  219. name = 'hubin'
  220. email = 'jobob@qq.com'
  221. }
  222. }
  223. withXml {
  224. def root = asNode()
  225. root.dependencies.'*'.findAll {
  226. def d = it
  227. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  228. dep.name == it.artifactId.text()
  229. }.each() {
  230. d.scope*.value = 'compile'
  231. d.appendNode('optional', true)
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. signing {
  239. sign publishing.publications.mavenJava
  240. }
  241. }
  242. }