build.gradle 9.8 KB

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