build.gradle 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. // 编译脚本
  2. buildscript {
  3. ext {
  4. // https://start.spring.io/actuator/info
  5. springBootVersion = "3.3.0"
  6. mybatisPlusVersion = "3.5.9"
  7. }
  8. // 仓库配置
  9. repositories {
  10. mavenLocal()
  11. maven { url 'https://maven.aliyun.com/repository/central' }
  12. maven { url 'https://maven.aliyun.com/repository/spring' }
  13. maven { url 'https://maven.aliyun.com/repository/google' }
  14. maven { url 'https://repo.spring.io/release' }
  15. maven { url 'https://repo.spring.io/milestone' }
  16. maven { url 'https://repo.spring.io/snapshot' }
  17. mavenCentral()
  18. }
  19. dependencies {
  20. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  21. }
  22. }
  23. description = "爱组搭低代码组件化开发平台"
  24. // 项目配置
  25. allprojects {
  26. group "com.aizuda"
  27. version "1.0.2"
  28. }
  29. // 子模块配置
  30. subprojects {
  31. apply plugin: 'java-library'
  32. apply plugin: 'maven-publish'
  33. apply plugin: 'signing'
  34. apply plugin: "io.spring.dependency-management"
  35. tasks.withType(JavaCompile) {
  36. options.encoding = 'UTF-8'
  37. options.warnings = false
  38. }
  39. // 仓库配置
  40. repositories {
  41. mavenLocal()
  42. maven { url 'https://maven.aliyun.com/repository/central' }
  43. maven { url 'https://maven.aliyun.com/repository/spring' }
  44. maven { url 'https://maven.aliyun.com/repository/google' }
  45. maven { url 'https://repo.spring.io/release' }
  46. maven { url 'https://repo.spring.io/milestone' }
  47. maven { url 'https://repo.spring.io/snapshot' }
  48. mavenCentral()
  49. }
  50. configurations {
  51. all*.exclude group: "ch.qos.logback"
  52. all*.exclude module: "spring-boot-starter-logging"
  53. // 使用Undertow 替代Tomcat
  54. all*.exclude group: "org.apache.tomcat"
  55. all*.exclude group: "org.apache.tomcat.embed"
  56. all*.exclude module: "spring-boot-starter-tomcat"
  57. }
  58. // 依赖管理
  59. dependencyManagement {
  60. imports {
  61. mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
  62. }
  63. dependencies {
  64. // 文档
  65. dependency("org.springdoc:springdoc-openapi-starter-common:2.5.0")
  66. dependency("jakarta.servlet:jakarta.servlet-api:6.1.0")
  67. // 工具类
  68. dependency("org.jodd:jodd-bean:5.1.6")
  69. dependency("commons-io:commons-io:2.16.1")
  70. dependency("commons-collections:commons-collections:3.2.2")
  71. dependency("org.apache.commons:commons-lang3:3.14.0")
  72. dependency("com.lmax:disruptor:3.4.4")
  73. // 爱组搭
  74. dependency("com.aizuda:aizuda-toolkit:1.0.0")
  75. // 单点登录
  76. dependency("com.baomidou:kisso:3.9.3")
  77. // orm db
  78. dependency("com.baomidou:mybatis-plus-spring-boot3-starter:${mybatisPlusVersion}")
  79. dependency("com.baomidou:mybatis-plus-jsqlparser:${mybatisPlusVersion}")
  80. dependency("com.baomidou:mybatis-plus-generator:${mybatisPlusVersion}")
  81. dependency("com.baomidou:mybatis-plus-extension:${mybatisPlusVersion}")
  82. dependency("org.postgresql:postgresql:42.7.3")
  83. }
  84. }
  85. // 依赖配置
  86. dependencies {
  87. compileOnly("org.projectlombok:lombok")
  88. annotationProcessor("org.projectlombok:lombok")
  89. testAnnotationProcessor("org.projectlombok:lombok")
  90. testCompileOnly("org.projectlombok:lombok")
  91. // 为了减少依赖 jar 体量,非公共依赖不要申明为 api 必须遵守在负责人同意允许后在对应项目中添加
  92. compileOnly("org.springframework.boot:spring-boot-starter-log4j2")
  93. compileOnly("jakarta.servlet:jakarta.servlet-api")
  94. // 编译测试
  95. testImplementation("org.springframework.boot:spring-boot-starter-test")
  96. }
  97. sourceCompatibility = JavaVersion.VERSION_17
  98. targetCompatibility = JavaVersion.VERSION_17
  99. tasks.withType(JavaCompile) {
  100. options.encoding = 'UTF-8'
  101. options.warnings = false
  102. options.deprecation = true
  103. options.compilerArgs += ["-parameters"]
  104. }
  105. tasks.withType(GenerateModuleMetadata) {
  106. enabled = false
  107. }
  108. task sourcesJar(type: Jar, dependsOn: classes) {
  109. archiveClassifier = 'sources'
  110. from sourceSets.main.allSource
  111. }
  112. javadoc {
  113. options {
  114. encoding "UTF-8"
  115. charSet 'UTF-8'
  116. author true
  117. version true
  118. failOnError false
  119. links "http://docs.oracle.com/javase/17/docs/api"
  120. }
  121. }
  122. task javadocJar(type: Jar) {
  123. archiveClassifier = 'javadoc'
  124. from javadoc
  125. }
  126. tasks.whenTaskAdded { task ->
  127. if (task.name.contains('signMavenJavaPublication')) {
  128. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  129. }
  130. }
  131. publishing {
  132. repositories {
  133. // maven {
  134. // def userName = System.getProperty("un")
  135. // def passWord = System.getProperty("ps")
  136. // def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
  137. // def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
  138. // url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  139. //
  140. // credentials {
  141. // username userName
  142. // password passWord
  143. // }
  144. // }
  145. maven {
  146. name = "Gitea"
  147. url = uri("http://git.aizuda.com/api/packages/aizuda/maven")
  148. allowInsecureProtocol = true
  149. credentials(HttpHeaderCredentials) {
  150. name = "Authorization"
  151. value = "token 7d725429ef7ac5c9fa9a6779f70032d6e42d7f34"
  152. }
  153. authentication {
  154. header(HttpHeaderAuthentication)
  155. }
  156. }
  157. }
  158. publications {
  159. mavenJava(MavenPublication) {
  160. from components.java
  161. // artifact sourcesJar
  162. artifact javadocJar
  163. pom {
  164. name = 'aizuda-framework'
  165. packaging 'jar'
  166. description = 'aizuda framework.'
  167. url = 'https://gitee.com/aizuda/aizuda-framework'
  168. scm {
  169. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  170. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  171. url = 'https://gitee.com/aizuda/aizuda-framework'
  172. }
  173. licenses {
  174. license {
  175. name = 'The Apache License, Version 2.0'
  176. url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
  177. }
  178. }
  179. developers {
  180. developer {
  181. id = 'aizuda'
  182. name = '青苗'
  183. email = 'jobob@qq.com'
  184. }
  185. }
  186. withXml {
  187. def root = asNode()
  188. root.dependencies.'*'.findAll {
  189. def d = it
  190. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  191. dep.name == it.artifactId.text()
  192. }.each() {
  193. d.scope*.value = 'compile'
  194. d.appendNode('optional', true)
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. signing {
  202. sign publishing.publications.mavenJava
  203. }
  204. }
  205. }