build.gradle 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // 编译脚本
  2. buildscript {
  3. ext {
  4. springBootVersion = "2.7.0"
  5. mybatisPlusVersion = "3.5.5"
  6. solonVersion = "2.5.11"
  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. mavenCentral()
  17. }
  18. dependencies {
  19. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  20. }
  21. }
  22. description = "FlowLong BPM"
  23. // 项目配置
  24. allprojects {
  25. group "com.flowlong"
  26. version "0.0.1-SNAPSHOT"
  27. }
  28. // 子模块配置
  29. subprojects {
  30. apply plugin: 'java-library'
  31. apply plugin: 'maven-publish'
  32. apply plugin: 'signing'
  33. apply plugin: "io.spring.dependency-management"
  34. tasks.withType(JavaCompile) {
  35. options.encoding = 'UTF-8'
  36. options.warnings = false
  37. }
  38. tasks.named('test') {
  39. useJUnitPlatform()
  40. }
  41. // 仓库配置
  42. repositories {
  43. mavenLocal()
  44. maven { url 'https://maven.aliyun.com/repository/central' }
  45. maven { url 'https://maven.aliyun.com/repository/spring' }
  46. maven { url 'https://maven.aliyun.com/repository/google' }
  47. maven { url 'https://repo.spring.io/release' }
  48. maven { url 'https://repo.spring.io/milestone' }
  49. maven { url 'https://repo.spring.io/snapshot' }
  50. maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
  51. mavenCentral()
  52. }
  53. // 依赖管理
  54. dependencyManagement {
  55. imports {
  56. mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
  57. }
  58. dependencies {
  59. dependency("mysql:mysql-connector-java:8.0.32")
  60. // orm db
  61. dependency("com.baomidou:mybatis-plus-boot-starter:${mybatisPlusVersion}")
  62. dependency("com.baomidou:mybatis-plus-core:${mybatisPlusVersion}")
  63. }
  64. }
  65. // 依赖配置
  66. dependencies {
  67. // 日志
  68. api("org.slf4j:slf4j-api")
  69. // lombok
  70. compileOnly("org.projectlombok:lombok")
  71. annotationProcessor("org.projectlombok:lombok")
  72. testAnnotationProcessor("org.projectlombok:lombok")
  73. testCompileOnly("org.projectlombok:lombok")
  74. // junit
  75. testCompileOnly("org.springframework.boot:spring-boot-starter-test")
  76. }
  77. tasks.named('test') {
  78. useJUnitPlatform()
  79. }
  80. // 编译环境 JDK-1.8+
  81. sourceCompatibility = JavaVersion.VERSION_1_8
  82. targetCompatibility = JavaVersion.VERSION_1_8
  83. tasks.withType(JavaCompile) {
  84. options.encoding = 'UTF-8'
  85. options.warnings = false
  86. options.deprecation = true
  87. options.compilerArgs += ["-parameters"]
  88. }
  89. tasks.withType(GenerateModuleMetadata) {
  90. enabled = false
  91. }
  92. task sourcesJar(type: Jar, dependsOn: classes) {
  93. archiveClassifier = 'sources'
  94. from sourceSets.main.allSource
  95. }
  96. javadoc {
  97. options {
  98. encoding "UTF-8"
  99. charSet 'UTF-8'
  100. author true
  101. version true
  102. failOnError false
  103. links "http://docs.oracle.com/javase/8/docs/api"
  104. }
  105. }
  106. task javadocJar(type: Jar) {
  107. archiveClassifier = 'javadoc'
  108. from javadoc
  109. }
  110. tasks.whenTaskAdded { task ->
  111. if (task.name.contains('signMavenJavaPublication')) {
  112. task.enabled = new File(project.property('signing.secretKeyRingFile') as String).isFile()
  113. }
  114. }
  115. publishing {
  116. repositories {
  117. maven {
  118. def userName = System.getProperty("un")
  119. def passWord = System.getProperty("ps")
  120. def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
  121. def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
  122. url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
  123. credentials {
  124. username userName
  125. password passWord
  126. }
  127. }
  128. }
  129. publications {
  130. mavenJava(MavenPublication) {
  131. from components.java
  132. artifact sourcesJar
  133. artifact javadocJar
  134. pom {
  135. name = 'flowlong'
  136. packaging 'jar'
  137. description = 'flowlong bpm engine'
  138. url = 'https://github.com/aizuda/flowlong'
  139. scm {
  140. connection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  141. developerConnection = 'scm:git@github.com:Codearte/gradle-nexus-staging-plugin.git'
  142. url = 'https://github.com/aizuda/flowlong'
  143. }
  144. licenses {
  145. license {
  146. name = 'The AGPL License, Version 3.0'
  147. url = 'https://www.gnu.org/licenses/agpl-3.0'
  148. }
  149. }
  150. developers {
  151. developer {
  152. id = 'aizuda'
  153. name = '青苗'
  154. email = 'jobob@qq.com'
  155. }
  156. }
  157. withXml {
  158. def root = asNode()
  159. root.dependencies.'*'.findAll {
  160. def d = it
  161. d.scope.text() == 'runtime' && project.configurations.findByName("implementation").allDependencies.find { dep ->
  162. dep.name == it.artifactId.text()
  163. }.each() {
  164. d.scope*.value = 'compile'
  165. d.appendNode('optional', true)
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. signing {
  174. sign publishing.publications.mavenJava
  175. }
  176. // 编译任务忽略案例模块
  177. afterEvaluate { project ->
  178. if (project.name == 'flowlong-spring-boot-example') {
  179. project.tasks.all {
  180. it.enabled = false
  181. }
  182. }
  183. }
  184. }