build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. "javax.servlet-api" : "javax.servlet:javax.servlet-api:4.0.1",
  46. "aspectjweaver" : "org.aspectj:aspectjweaver:1.9.6",
  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.1",
  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.72",
  57. "jackson" : "com.fasterxml.jackson.core:jackson-databind:2.11.1",
  58. "gson" : "com.google.code.gson:gson:2.8.6",
  59. "lagarto" : "org.jodd:jodd-lagarto:5.1.5",
  60. //datasource
  61. "p6spy" : "p6spy:p6spy:3.9.0",
  62. "sqlserver" : "com.microsoft.sqlserver:sqljdbc4:4.0",
  63. "postgresql" : "org.postgresql:postgresql:42.2.14",
  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.21",
  69. "sqlite" : "org.xerial:sqlite-jdbc:3.32.3.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.8.RELEASE",
  74. "swagger-annotations" : "io.swagger:swagger-annotations:1.6.2",
  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. "mybatis-caffeine" : "org.mybatis.caches:mybatis-caffeine:1.0.0-beta1"
  79. ]
  80. }
  81. allprojects {
  82. group = 'com.baomidou'
  83. version = "3.3.3.6-SNAPSHOT"
  84. }
  85. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  86. subprojects {
  87. apply plugin: 'java-library'
  88. apply plugin: 'signing'
  89. apply plugin: 'maven-publish'
  90. apply plugin: 'com.github.hierynomus.license'
  91. sourceCompatibility = "${javaVersion}"
  92. targetCompatibility = "${javaVersion}"
  93. tasks.withType(JavaCompile) {
  94. options.encoding = 'UTF-8'
  95. options.warnings = false
  96. options.deprecation = true
  97. options.compilerArgs += ["-parameters"]
  98. }
  99. tasks.withType(GenerateModuleMetadata) {
  100. enabled = false
  101. }
  102. jar {
  103. afterEvaluate {
  104. manifest {
  105. attributes 'Implementation-Version': archiveVersion
  106. attributes 'Built-Gradle': gradle.gradleVersion
  107. attributes 'Bundle-DocURL': 'https://mybatis.plus/'
  108. attributes 'Build-OS': System.getProperty("os.name")
  109. attributes 'Built-By': System.getProperty("user.name")
  110. attributes 'Build-Jdk': System.getProperty("java.version")
  111. attributes 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
  112. }
  113. }
  114. }
  115. license {
  116. encoding = "UTF-8"
  117. header = rootProject.file("license.txt")
  118. includes(["**/*.java", "**/*.kt"])
  119. exclude "**/test/**/*.kt"
  120. exclude "**/test/**/*.java"
  121. exclude "**/*Test.java"
  122. exclude "**/TableNameParser.java"
  123. exclude "**/Maps.java"
  124. mapping "java", "SLASHSTAR_STYLE"
  125. mapping "kt", "SLASHSTAR_STYLE"
  126. ignoreFailures = true
  127. }
  128. repositories {
  129. mavenLocal()
  130. maven { url "https://maven.aliyun.com/repository/public" }
  131. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  132. jcenter()
  133. }
  134. dependencies {
  135. annotationProcessor "${lib.lombok}"
  136. compileOnly "${lib.lombok}"
  137. testAnnotationProcessor "${lib.lombok}"
  138. testCompileOnly "${lib.lombok}"
  139. testImplementation "${lib["assertj-core"]}"
  140. testImplementation "${lib["junit-jupiter-api"]}"
  141. testRuntimeOnly "${lib["junit-jupiter-engine"]}"
  142. testImplementation "org.mockito:mockito-junit-jupiter:3.4.4"
  143. testImplementation "${lib["lagarto"]}"
  144. testImplementation "${lib["logback-classic"]}"
  145. }
  146. //noinspection GroovyAssignabilityCheck
  147. task sourcesJar(type: Jar) {
  148. archiveClassifier = 'sources'
  149. from sourceSets.main.allSource
  150. }
  151. javadoc {
  152. afterEvaluate {
  153. configure(options) {
  154. encoding "UTF-8"
  155. charSet 'UTF-8'
  156. author true
  157. version true
  158. failOnError false
  159. links "http://docs.oracle.com/javase/8/docs/api"
  160. }
  161. }
  162. }
  163. test {
  164. dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
  165. useJUnitPlatform()
  166. exclude("**/generator/**")
  167. exclude("**/mysql/**")
  168. exclude("**/phoenix/**")
  169. }
  170. task javadocJar(type: Jar) {
  171. archiveClassifier = 'javadoc'
  172. from javadoc
  173. }
  174. tasks.whenTaskAdded { task ->
  175. if (task.name.contains('signMavenJavaPublication')) {
  176. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  177. }
  178. }
  179. publishing {
  180. repositories {
  181. maven {
  182. def userName = System.getProperty("un")
  183. def passWord = System.getProperty("ps")
  184. def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  185. def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  186. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  187. credentials {
  188. username userName
  189. password passWord
  190. }
  191. }
  192. }
  193. publications {
  194. mavenJava(MavenPublication) {
  195. from components.java
  196. artifact sourcesJar
  197. artifact javadocJar
  198. pom {
  199. name = 'mybatis-plus'
  200. packaging 'jar'
  201. description = 'An enhanced toolkit of Mybatis to simplify development.'
  202. url = 'https://github.com/baomidou/mybatis-plus'
  203. scm {
  204. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  205. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  206. url = 'https://github.com/baomidou/mybatis-plus'
  207. }
  208. licenses {
  209. license {
  210. name = 'The Apache License, Version 2.0'
  211. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  212. }
  213. }
  214. developers {
  215. developer {
  216. id = 'baomidou'
  217. name = 'hubin'
  218. email = 'jobob@qq.com'
  219. }
  220. }
  221. withXml {
  222. def root = asNode()
  223. root.dependencies.'*'.findAll {
  224. def d = it
  225. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  226. dep.name == it.artifactId.text()
  227. }.each() {
  228. d.scope*.value = 'compile'
  229. d.appendNode('optional', true)
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. signing {
  237. sign publishing.publications.mavenJava
  238. }
  239. }
  240. }