build.gradle 10 KB

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