build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. buildscript {
  2. repositories {
  3. maven { url 'https://maven.aliyun.com/repository/public' }
  4. gradlePluginPortal()
  5. }
  6. dependencies {
  7. //jhipster-needle-gradle-buildscript-dependency - JHipster will add additional gradle build script plugins here
  8. }
  9. }
  10. plugins {
  11. id "java"
  12. id "maven-publish"
  13. id "idea"
  14. id "eclipse"
  15. id "jacoco"
  16. id "org.springframework.boot"
  17. id "com.google.cloud.tools.jib"
  18. id "com.gorylenko.gradle-git-properties"
  19. id "org.liquibase.gradle"
  20. id "org.sonarqube"
  21. id "io.spring.nohttp"
  22. id "com.github.andygoossens.gradle-modernizer-plugin"
  23. //jhipster-needle-gradle-plugins - JHipster will add additional gradle plugins here
  24. id "org.springframework.boot.experimental.thin-launcher" version "1.0.28.RELEASE" apply false
  25. id "io.spring.dependency-management" version "1.0.13.RELEASE" apply false
  26. }
  27. group = "com.ruowei.trade"
  28. version = "0.0.1-SNAPSHOT"
  29. description = ""
  30. sourceCompatibility = 11
  31. targetCompatibility = 11
  32. assert System.properties["java.specification.version"] == "11" || "12" || "13" || "14" || "15" || "16" || "17" || "18"
  33. apply from: "gradle/docker.gradle"
  34. apply from: "gradle/sonar.gradle"
  35. //jhipster-needle-gradle-apply-from - JHipster will add additional gradle scripts to be applied here
  36. if (project.hasProperty("prod") || project.hasProperty("gae")) {
  37. apply from: "gradle/profile_prod.gradle"
  38. } else if (project.hasProperty("beta")) {
  39. apply from: "gradle/profile_beta.gradle"
  40. } else {
  41. apply from: "gradle/profile_dev.gradle"
  42. }
  43. if (project.hasProperty("war")) {
  44. apply from: "gradle/war.gradle"
  45. }
  46. if (project.hasProperty("gae")) {
  47. apply plugin: 'maven'
  48. apply plugin: 'org.springframework.boot.experimental.thin-launcher'
  49. apply plugin: 'io.spring.dependency-management'
  50. dependencyManagement {
  51. imports {
  52. mavenBom "tech.jhipster:jhipster-dependencies:${jhipsterDependenciesVersion}"
  53. }
  54. }
  55. appengineStage.dependsOn thinResolve
  56. }
  57. if (project.hasProperty("thin")) {
  58. apply from: "gradle/thin.gradle"
  59. bootJarMainClassName.dependsOn thinPom
  60. }
  61. idea {
  62. module {
  63. excludeDirs += files("node_modules")
  64. }
  65. }
  66. eclipse {
  67. sourceSets {
  68. main {
  69. java {
  70. srcDirs += ["build/generated/sources/annotationProcessor/java/main"]
  71. }
  72. }
  73. }
  74. }
  75. defaultTasks "bootRun"
  76. springBoot {
  77. mainClass = "com.ruowei.trade.TradeApp"
  78. }
  79. test {
  80. useJUnitPlatform()
  81. exclude "**/*IT*", "**/*IntTest*"
  82. testLogging {
  83. events 'FAILED', 'SKIPPED'
  84. }
  85. jvmArgs += '-Djava.security.egd=file:/dev/./urandom -Xmx512m'
  86. // uncomment if the tests reports are not generated
  87. // see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
  88. // ignoreFailures true
  89. reports.html.enabled = false
  90. }
  91. modernizer {
  92. failOnViolations = true
  93. includeTestClasses = true
  94. }
  95. check.dependsOn integrationTest
  96. task testReport(type: TestReport) {
  97. destinationDir = file("$buildDir/reports/tests")
  98. reportOn test
  99. }
  100. task integrationTestReport(type: TestReport) {
  101. destinationDir = file("$buildDir/reports/tests")
  102. reportOn integrationTest
  103. }
  104. if (!project.hasProperty("runList")) {
  105. project.ext.runList = "main"
  106. }
  107. project.ext.diffChangelogFile = "src/main/resources/config/liquibase/changelog/" + new Date().format("yyyyMMddHHmmss") + "_changelog.xml"
  108. liquibase {
  109. activities {
  110. main {
  111. driver "com.mysql.cj.jdbc.Driver"
  112. url "jdbc:mysql://localhost:3306/trade"
  113. username "root"
  114. password ""
  115. changeLogFile "src/main/resources/config/liquibase/master.xml"
  116. defaultSchemaName "trade"
  117. logLevel "debug"
  118. classpath "src/main/resources/"
  119. }
  120. diffLog {
  121. driver "com.mysql.cj.jdbc.Driver"
  122. url "jdbc:mysql://localhost:3306/trade"
  123. username "root"
  124. password ""
  125. changeLogFile project.ext.diffChangelogFile
  126. referenceUrl "hibernate:spring:com.ruowei.trade.domain?dialect=org.hibernate.dialect.MySQL8Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy"
  127. defaultSchemaName "trade"
  128. logLevel "debug"
  129. classpath "$buildDir/classes/java/main"
  130. }
  131. }
  132. runList = project.ext.runList
  133. }
  134. gitProperties {
  135. failOnNoGitDirectory = false
  136. keys = ["git.branch", "git.commit.id.abbrev", "git.commit.id.describe"]
  137. }
  138. checkstyle {
  139. toolVersion "${checkstyleVersion}"
  140. configFile file("checkstyle.xml")
  141. checkstyleTest.enabled = false
  142. }
  143. nohttp {
  144. source.include "build.gradle", "README.md"
  145. }
  146. configurations {
  147. providedRuntime
  148. implementation.exclude module: "spring-boot-starter-tomcat"
  149. all {
  150. resolutionStrategy {
  151. // Inherited version from Spring Boot can't be used because of regressions:
  152. // To be removed as soon as spring-boot use the same version
  153. force 'org.liquibase:liquibase-core:4.15.0'
  154. }
  155. }
  156. }
  157. bootJar {
  158. baseName = "trade"
  159. version = ''
  160. }
  161. repositories {
  162. // Local maven repository is required for libraries built locally with maven like development jhipster-bom.
  163. mavenLocal()
  164. mavenCentral()
  165. maven { url 'https://maven.aliyun.com/repository/public' }
  166. maven { url "https://jitpack.io" }
  167. jcenter()
  168. google()
  169. //jhipster-needle-gradle-repositories - JHipster will add additional repositories
  170. }
  171. dependencies {
  172. // import JHipster dependencies BOM
  173. if (!project.hasProperty("gae")) {
  174. implementation platform("tech.jhipster:jhipster-dependencies:${jhipsterDependenciesVersion}")
  175. }
  176. // Use ", version: jhipsterDependenciesVersion, changing: true" if you want
  177. // to use a SNAPSHOT release instead of a stable release
  178. implementation group: "tech.jhipster", name: "jhipster-framework"
  179. implementation "javax.annotation:javax.annotation-api"
  180. implementation "org.springframework.boot:spring-boot-starter-cache"
  181. implementation "com.fasterxml.jackson.module:jackson-module-jaxb-annotations"
  182. implementation "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5"
  183. implementation "com.fasterxml.jackson.datatype:jackson-datatype-hppc"
  184. implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
  185. testImplementation "org.testcontainers:junit-jupiter"
  186. testImplementation "org.testcontainers:testcontainers"
  187. implementation("org.springdoc:springdoc-openapi-ui:1.6.11")
  188. implementation "com.zaxxer:HikariCP"
  189. implementation "org.apache.commons:commons-lang3"
  190. implementation "javax.cache:cache-api"
  191. implementation "org.ehcache:ehcache"
  192. implementation "org.hibernate:hibernate-jcache"
  193. annotationProcessor "org.hibernate:hibernate-jpamodelgen:${hibernateVersion}"
  194. implementation "org.hibernate:hibernate-core"
  195. implementation "org.hibernate.validator:hibernate-validator"
  196. implementation "org.liquibase:liquibase-core"
  197. liquibaseRuntime "org.liquibase:liquibase-core"
  198. annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}"
  199. implementation "org.springframework.boot:spring-boot-loader-tools"
  200. implementation "org.springframework.boot:spring-boot-starter-actuator"
  201. implementation "org.springframework.boot:spring-boot-starter-data-jpa"
  202. testImplementation "org.testcontainers:jdbc"
  203. implementation "org.springframework.boot:spring-boot-starter-logging"
  204. implementation "org.springframework.boot:spring-boot-starter-mail"
  205. implementation "org.springframework.boot:spring-boot-starter-security"
  206. implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
  207. implementation "org.springframework.boot:spring-boot-starter-web"
  208. testImplementation "org.springframework.boot:spring-boot-starter-test"
  209. testImplementation "org.springframework.boot:spring-boot-test"
  210. testImplementation "org.springframework.security:spring-security-test"
  211. testImplementation "com.tngtech.archunit:archunit-junit5-api:${archunitJunit5Version}"
  212. testRuntimeOnly "com.tngtech.archunit:archunit-junit5-engine:${archunitJunit5Version}"
  213. implementation "org.zalando:problem-spring-web"
  214. implementation "org.springframework.boot:spring-boot-starter-undertow"
  215. implementation "io.jsonwebtoken:jjwt-api"
  216. if (!project.hasProperty("gae")) {
  217. runtimeOnly "io.jsonwebtoken:jjwt-impl"
  218. runtimeOnly "io.jsonwebtoken:jjwt-jackson"
  219. } else {
  220. implementation "io.jsonwebtoken:jjwt-impl"
  221. implementation "io.jsonwebtoken:jjwt-jackson"
  222. }
  223. implementation "org.springframework.security:spring-security-data"
  224. implementation "io.micrometer:micrometer-registry-prometheus"
  225. implementation "io.dropwizard.metrics:metrics-core"
  226. liquibaseRuntime sourceSets.main.compileClasspath
  227. liquibaseRuntime "org.liquibase.ext:liquibase-hibernate5:${liquibaseHibernate5Version}"
  228. //jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
  229. compileOnly "org.projectlombok:lombok:1.18.24"
  230. annotationProcessor "org.projectlombok:lombok:1.18.24"
  231. implementation "com.querydsl:querydsl-core:5.0.0"
  232. implementation "com.querydsl:querydsl-jpa:5.0.0"
  233. implementation "org.mapstruct:mapstruct:${mapstructVersion}"
  234. annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
  235. annotationProcessor "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
  236. annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jpa"
  237. implementation "com.github.xiaoymin:knife4j-springdoc-ui:3.0.3"
  238. implementation "com.github.wechatpay-apiv3:wechatpay-java:0.2.10"
  239. // ali-fastjson
  240. implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.83'
  241. // https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-core
  242. implementation group: 'com.aliyun', name: 'aliyun-java-sdk-core', version: '4.5.18'
  243. implementation "com.github.yitter:yitter-idgenerator:1.0.6"
  244. // MapperUtil
  245. implementation('org.modelmapper:modelmapper:1.1.0')
  246. // hutool
  247. implementation 'cn.hutool:hutool-all:5.8.10'
  248. // 依赖libs目录下所有以.jar结尾的文件
  249. implementation fileTree(dir: 'lib', includes: ['*.jar'])
  250. // 依赖某个jar文件
  251. // implementation files('lib/xxx.jar')
  252. // 依赖libs目录下除了xxx.jar以外的所有以.jar结尾的文件
  253. // implementation fileTree(dir: 'lib', excludes: ['xxx.jar'], includes: ['*.jar'])
  254. // compile fileTree(dir:'src/main/resources/lib',includes:['*jar'])
  255. // implementation fileTree(dir:'src/main/resources/lib',includes:['*jar'])
  256. }
  257. if (project.hasProperty("gae")) {
  258. task createPom {
  259. def basePath = 'build/resources/main/META-INF/maven'
  260. doLast {
  261. pom {
  262. withXml(dependencyManagement.pomConfigurer)
  263. }.writeTo("${basePath}/${project.group}/${project.name}/pom.xml")
  264. }
  265. }
  266. bootJar.dependsOn = [createPom]
  267. }
  268. task cleanResources(type: Delete) {
  269. delete "build/resources"
  270. }
  271. tasks.named("test").configure {
  272. enabled = false
  273. }
  274. tasks.named("integrationTest").configure {
  275. enabled = false
  276. }
  277. tasks.named("checkstyleMain").configure {
  278. enabled = false
  279. }
  280. wrapper {
  281. gradleVersion = "7.4.2"
  282. }
  283. compileJava.dependsOn processResources
  284. processResources.dependsOn bootBuildInfo