build.gradle.kts 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. buildscript {
  2. repositories {
  3. maven("https://plugins.gradle.org/m2/")
  4. }
  5. dependencies {
  6. classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10")
  7. classpath("com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3")
  8. }
  9. }
  10. plugins {
  11. `java-library`
  12. signing
  13. `maven-publish`
  14. }
  15. // versions
  16. val javaVersion = JavaVersion.VERSION_1_8
  17. val mybatisSpringVersion = "2.0.0"
  18. val mybatisVersion = "3.5.0"
  19. val springVersion = "5.1.4.RELEASE"
  20. val jsqlparserVersion = "1.3"
  21. val junitVersion = "5.4.0-RC1" // TODO 5.4.0 预计将与 2019-02-06 发布,届时应替换成正式版本
  22. val lombokVersion = "1.18.4"
  23. val cglibVersion = "3.2.6"
  24. // libs
  25. val lib = mapOf(
  26. "kotlin-reflect" to "org.jetbrains.kotlin:kotlin-reflect:1.3.10",
  27. "kotlin-stdlib-jdk8" to "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.10",
  28. "jsqlparser" to "com.github.jsqlparser:jsqlparser:$jsqlparserVersion",
  29. "mybatis-spring" to "org.mybatis:mybatis-spring:$mybatisSpringVersion",
  30. "mybatis" to "org.mybatis:mybatis:$mybatisVersion",
  31. "spring-context-support" to "org.springframework:spring-context-support:$springVersion",
  32. "spring-jdbc" to "org.springframework:spring-jdbc:$springVersion",
  33. "spring-tx" to "org.springframework:spring-tx:$springVersion",
  34. "spring-web" to "org.springframework:spring-web:$springVersion",
  35. "spring-aop" to "org.springframework:spring-aop:$springVersion",
  36. "cglib" to "cglib:cglib:$cglibVersion",
  37. "lombok" to "org.projectlombok:lombok:$lombokVersion",
  38. "javax.servlet-api" to "javax.servlet:javax.servlet-api:4.0.1",
  39. "aspectjweaver" to "org.aspectj:aspectjweaver:1.8.9",
  40. "mockito" to "org.mockito:mockito-core:2.13.0",
  41. "mybatis-ehcache" to "org.mybatis.caches:mybatis-ehcache:1.1.0",
  42. "slf4j-api" to "org.slf4j:slf4j-api:1.7.25",
  43. "logback-classic" to "ch.qos.logback:logback-classic:1.2.3",
  44. // test
  45. "spring-test" to "org.springframework:spring-test:$springVersion",
  46. "junit-jupiter-api" to "org.junit.jupiter:junit-jupiter-api:$junitVersion",
  47. "junit-jupiter-engine" to "org.junit.jupiter:junit-jupiter-engine:$junitVersion",
  48. "mockito-all" to "org.mockito:mockito-all:1.10.19",
  49. "fastjson" to "com.alibaba:fastjson:1.2.49",
  50. "jackson" to "com.fasterxml.jackson.core:jackson-databind:2.9.6",
  51. "tomcatjdbc" to "org.apache.tomcat:tomcat-jdbc:9.0.2",
  52. // datasource
  53. "hikaricp" to "com.zaxxer:HikariCP:2.7.0",
  54. "druid" to "com.alibaba:druid:1.0.29",
  55. "commons-dbcp2" to "org.apache.commons:commons-dbcp2:2.1.1",
  56. "sqlserver" to "com.microsoft.sqlserver:sqljdbc4:4.0",
  57. "postgresql" to "org.postgresql:postgresql:9.4.1212",
  58. "oracle" to fileTree("libs/ojdbc-11.2.0.3-jdk16.jar"),
  59. "h2" to "com.h2database:h2:1.4.194",
  60. "mysql" to "mysql:mysql-connector-java:5.1.38",
  61. // code generator
  62. "velocity" to "org.apache.velocity:velocity-engine-core:2.0",
  63. "freemarker" to "org.freemarker:freemarker:2.3.9",
  64. "beetl" to "com.ibeetl:beetl:2.9.6"
  65. )
  66. // ext
  67. extra["lib"] = lib
  68. allprojects {
  69. group = "com.baomidou"
  70. version = "3.0.8.3-SNAPSHOT"
  71. }
  72. description = "Mybatis 增强工具包 - 只做增强不做改变,简化CRUD操作"
  73. subprojects {
  74. // 插件
  75. apply(plugin = "org.gradle.java-library")
  76. apply(plugin = "org.gradle.maven-publish")
  77. apply(plugin = "org.gradle.signing")
  78. // Java 版本
  79. configure<JavaPluginConvention> {
  80. sourceCompatibility = javaVersion
  81. targetCompatibility = javaVersion
  82. }
  83. // 编译器配置
  84. tasks.withType<JavaCompile> {
  85. options.encoding = "UTF-8"
  86. options.isDeprecation = true
  87. options.compilerArgs.add("-parameters")
  88. }
  89. tasks.withType<Jar> {
  90. afterEvaluate {
  91. manifest {
  92. attributes["Implementation-Version"] = version
  93. }
  94. }
  95. }
  96. repositories {
  97. mavenLocal()
  98. maven("http://maven.aliyun.com/nexus/contencommons-dbcpt/groups/public/")
  99. maven("https://oss.sonatype.org/content/repositories/snapshots/")
  100. maven("http://www.cameliatk.jp/maven2/repository/thirdparty")
  101. jcenter()
  102. }
  103. dependencies {
  104. annotationProcessor("${lib["lombok"]}")
  105. compileOnly("${lib["lombok"]}")
  106. testAnnotationProcessor("${lib["lombok"]}")
  107. testCompileOnly("${lib["mockito-all"]}")
  108. testCompile("${lib["junit-jupiter-api"]}")
  109. testRuntime("${lib["junit-jupiter-engine"]}")
  110. testCompile("org.mockito:mockito-junit-jupiter:2.23.4")
  111. }
  112. val sourcesJar by tasks.registering(Jar::class) {
  113. dependsOn(JavaPlugin.CLASSES_TASK_NAME)
  114. archiveClassifier.set("source")
  115. from(sourceSets["main"].allJava)
  116. }
  117. tasks.withType<Javadoc> {
  118. options.encoding = "UTF-8"
  119. isFailOnError = false
  120. (options as? StandardJavadocDocletOptions)?.also {
  121. it.charSet = "UTF-8"
  122. it.isAuthor = true
  123. it.isVersion = true
  124. it.links = listOf("https://docs.oracle.com/javase/8/docs/api")
  125. if (JavaVersion.current().isJava9Compatible) {
  126. it.addBooleanOption("html5", true)
  127. }
  128. }
  129. }
  130. val javadocJar by tasks.registering(Jar::class) {
  131. dependsOn(JavaPlugin.JAVADOC_TASK_NAME)
  132. archiveClassifier.set("javadoc")
  133. from(tasks["javadoc"])
  134. }
  135. tasks.whenTaskAdded {
  136. if (this.name.contains("signMavenJavaPublication")) {
  137. this.enabled = File(project.property("signing.secretKeyRingFile") as String).isFile
  138. }
  139. }
  140. publishing {
  141. repositories {
  142. maven {
  143. val userName = System.getProperty("un")
  144. val passWord = System.getProperty("ps")
  145. val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
  146. val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
  147. setUrl(if (version.toString().endsWith("RELEASE")) releasesRepoUrl else snapshotsRepoUrl)
  148. credentials {
  149. username = userName
  150. password = passWord
  151. }
  152. }
  153. }
  154. publications {
  155. register("mavenJava", MavenPublication::class) {
  156. pom {
  157. name.set("mybatis-plus")
  158. description.set("An enhanced toolkit of Mybatis to simplify development.")
  159. inceptionYear.set("2016")
  160. url.set("https://github.com/baomidou/mybatis-plus")
  161. artifactId = project.name
  162. groupId = "${project.group}"
  163. version = "${project.version}"
  164. packaging = "jar"
  165. organization {
  166. name.set("baomidou")
  167. }
  168. scm {
  169. connection.set("scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git")
  170. developerConnection.set("scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git")
  171. url.set("https://github.com/baomidou/mybatis-plus")
  172. }
  173. licenses {
  174. license {
  175. name.set("The Apache License, Version 2.0")
  176. url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
  177. }
  178. }
  179. developers {
  180. developer {
  181. id.set("baomidou")
  182. name.set("hubin")
  183. email.set("jobob@qq.com")
  184. }
  185. }
  186. }
  187. from(components["java"])
  188. artifact(sourcesJar.get())
  189. artifact(javadocJar.get())
  190. }
  191. }
  192. }
  193. signing {
  194. sign(publishing.publications.getByName("mavenJava"))
  195. }
  196. }