build.gradle 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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.11.RELEASE" apply false
  26. }
  27. group = "com.ruowei.clibra"
  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 {
  39. apply from: "gradle/profile_dev.gradle"
  40. }
  41. if (project.hasProperty("war")) {
  42. apply from: "gradle/war.gradle"
  43. }
  44. if (project.hasProperty("gae")) {
  45. apply plugin: 'maven'
  46. apply plugin: 'org.springframework.boot.experimental.thin-launcher'
  47. apply plugin: 'io.spring.dependency-management'
  48. dependencyManagement {
  49. imports {
  50. mavenBom "tech.jhipster:jhipster-dependencies:${jhipsterDependenciesVersion}"
  51. }
  52. }
  53. appengineStage.dependsOn thinResolve
  54. }
  55. if (project.hasProperty("thin")) {
  56. apply from: "gradle/thin.gradle"
  57. bootJarMainClassName.dependsOn thinPom
  58. }
  59. idea {
  60. module {
  61. excludeDirs += files("node_modules")
  62. }
  63. }
  64. eclipse {
  65. sourceSets {
  66. main {
  67. java {
  68. srcDirs += ["build/generated/sources/annotationProcessor/java/main"]
  69. }
  70. }
  71. }
  72. }
  73. defaultTasks "bootRun"
  74. springBoot {
  75. mainClass = "com.ruowei.clibra.ClibraApp"
  76. }
  77. test {
  78. enabled = false
  79. useJUnitPlatform()
  80. exclude "**/*IT*", "**/*IntTest*"
  81. testLogging {
  82. events 'FAILED', 'SKIPPED'
  83. }
  84. jvmArgs += '-Djava.security.egd=file:/dev/./urandom -Xmx256m'
  85. // uncomment if the tests reports are not generated
  86. // see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
  87. // ignoreFailures true
  88. reports.html.enabled = false
  89. }
  90. modernizer {
  91. failOnViolations = true
  92. includeTestClasses = true
  93. }
  94. task integrationTest(type: Test) {
  95. integrationTest.enabled = false
  96. useJUnitPlatform()
  97. description = "Execute integration tests."
  98. group = "verification"
  99. include "**/*IT*", "**/*IntTest*"
  100. testLogging {
  101. events 'FAILED', 'SKIPPED'
  102. }
  103. jvmArgs += '-Djava.security.egd=file:/dev/./urandom -Xmx256m'
  104. if (project.hasProperty('testcontainers')) {
  105. environment 'spring.profiles.active', 'testcontainers'
  106. }
  107. // uncomment if the tests reports are not generated
  108. // see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
  109. // ignoreFailures true
  110. reports.html.enabled = false
  111. }
  112. check.dependsOn integrationTest
  113. task testReport(type: TestReport) {
  114. destinationDir = file("$buildDir/reports/tests")
  115. reportOn test
  116. }
  117. task integrationTestReport(type: TestReport) {
  118. destinationDir = file("$buildDir/reports/tests")
  119. reportOn integrationTest
  120. }
  121. if (!project.hasProperty("runList")) {
  122. project.ext.runList = "main"
  123. }
  124. project.ext.diffChangelogFile = "src/main/resources/config/liquibase/changelog/" + new Date().format("yyyyMMddHHmmss") + "_changelog.xml"
  125. liquibase {
  126. activities {
  127. main {
  128. driver "com.mysql.cj.jdbc.Driver"
  129. url "jdbc:mysql://localhost:3306/ecsp"
  130. username "root"
  131. password ""
  132. changeLogFile "src/main/resources/config/liquibase/master.xml"
  133. defaultSchemaName "clibra"
  134. logLevel "debug"
  135. classpath "src/main/resources/"
  136. }
  137. diffLog {
  138. driver "com.mysql.cj.jdbc.Driver"
  139. url "jdbc:mysql://localhost:3306/ecsp"
  140. username "root"
  141. password ""
  142. changeLogFile project.ext.diffChangelogFile
  143. referenceUrl "hibernate:spring:com.ruowei.clibra.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"
  144. defaultSchemaName "clibra"
  145. logLevel "debug"
  146. classpath "$buildDir/classes/java/main"
  147. }
  148. }
  149. runList = project.ext.runList
  150. }
  151. gitProperties {
  152. failOnNoGitDirectory = false
  153. keys = ["git.branch", "git.commit.id.abbrev", "git.commit.id.describe"]
  154. }
  155. checkstyle {
  156. toolVersion "${checkstyleVersion}"
  157. configFile file("checkstyle.xml")
  158. checkstyleTest.enabled = false
  159. }
  160. nohttp {
  161. source.include "build.gradle", "README.md"
  162. }
  163. configurations {
  164. providedRuntime
  165. implementation.exclude module: "spring-boot-starter-tomcat"
  166. all {
  167. resolutionStrategy {
  168. // Inherited version from Spring Boot can't be used because of regressions:
  169. // To be removed as soon as spring-boot use the same version
  170. force 'org.liquibase:liquibase-core:4.6.1'
  171. }
  172. }
  173. }
  174. bootJar {
  175. baseName = "clibra"
  176. version = ''
  177. }
  178. repositories {
  179. // Local maven repository is required for libraries built locally with maven like development jhipster-bom.
  180. mavenLocal()
  181. maven { url 'https://maven.aliyun.com/repository/public' }
  182. maven { url 'https://maven.aliyun.com/repository/jcenter' }
  183. maven { url 'https://maven.aliyun.com/repository/google' }
  184. maven { url 'https://repo.spring.io/milestone' }
  185. maven { url "https://jitpack.io" }
  186. mavenCentral()
  187. gradlePluginPortal()
  188. //jhipster-needle-gradle-repositories - JHipster will add additional repositories
  189. }
  190. dependencies {
  191. // import JHipster dependencies BOM
  192. if (!project.hasProperty("gae")) {
  193. implementation platform("tech.jhipster:jhipster-dependencies:${jhipsterDependenciesVersion}")
  194. }
  195. // Use ", version: jhipsterDependenciesVersion, changing: true" if you want
  196. // to use a SNAPSHOT release instead of a stable release
  197. implementation group: "tech.jhipster", name: "jhipster-framework"
  198. implementation "javax.annotation:javax.annotation-api"
  199. implementation "org.springframework.boot:spring-boot-starter-cache"
  200. implementation "io.dropwizard.metrics:metrics-core"
  201. implementation "io.micrometer:micrometer-registry-prometheus"
  202. implementation "com.fasterxml.jackson.datatype:jackson-datatype-hppc"
  203. implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
  204. implementation "com.fasterxml.jackson.module:jackson-module-jaxb-annotations"
  205. implementation "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5"
  206. implementation "com.fasterxml.jackson.core:jackson-annotations"
  207. implementation "com.fasterxml.jackson.core:jackson-databind"
  208. implementation "javax.cache:cache-api"
  209. implementation "org.hibernate:hibernate-core"
  210. implementation "com.zaxxer:HikariCP"
  211. implementation "org.apache.commons:commons-lang3"
  212. implementation "javax.transaction:javax.transaction-api"
  213. implementation "org.ehcache:ehcache"
  214. implementation "org.hibernate:hibernate-jcache"
  215. implementation "org.hibernate:hibernate-entitymanager"
  216. implementation "org.hibernate.validator:hibernate-validator"
  217. implementation "org.liquibase:liquibase-core"
  218. liquibaseRuntime "org.liquibase:liquibase-core"
  219. liquibaseRuntime "org.liquibase.ext:liquibase-hibernate5:${liquibaseHibernate5Version}"
  220. liquibaseRuntime sourceSets.main.compileClasspath
  221. implementation "org.springframework.boot:spring-boot-loader-tools"
  222. implementation "org.springframework.boot:spring-boot-starter-mail"
  223. implementation "org.springframework.boot:spring-boot-starter-logging"
  224. implementation "org.springframework.boot:spring-boot-starter-actuator"
  225. implementation "org.springframework.boot:spring-boot-starter-data-jpa"
  226. testImplementation "org.testcontainers:mysql"
  227. implementation "org.springframework.boot:spring-boot-starter-security"
  228. implementation("org.springframework.boot:spring-boot-starter-web") {
  229. exclude module: "spring-boot-starter-tomcat"
  230. }
  231. implementation "org.springframework.boot:spring-boot-starter-undertow"
  232. implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
  233. implementation "org.zalando:problem-spring-web"
  234. implementation "org.springframework.security:spring-security-config"
  235. implementation "org.springframework.security:spring-security-data"
  236. implementation "org.springframework.security:spring-security-web"
  237. implementation "io.jsonwebtoken:jjwt-api"
  238. if (!project.hasProperty("gae")) {
  239. runtimeOnly "io.jsonwebtoken:jjwt-impl"
  240. runtimeOnly "io.jsonwebtoken:jjwt-jackson"
  241. } else {
  242. implementation "io.jsonwebtoken:jjwt-impl"
  243. implementation "io.jsonwebtoken:jjwt-jackson"
  244. }
  245. implementation("org.springdoc:springdoc-openapi-ui:1.6.8")
  246. implementation("io.springfox:springfox-swagger2:2.2.2")
  247. implementation("io.springfox:springfox-swagger-ui:2.2.2")
  248. implementation "mysql:mysql-connector-java"
  249. liquibaseRuntime "mysql:mysql-connector-java"
  250. implementation "org.mapstruct:mapstruct:${mapstructVersion}"
  251. annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
  252. annotationProcessor "org.hibernate:hibernate-jpamodelgen:${hibernateVersion}"
  253. annotationProcessor "org.glassfish.jaxb:jaxb-runtime:${jaxbRuntimeVersion}"
  254. annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}"
  255. testImplementation "org.springframework.boot:spring-boot-starter-test"
  256. testImplementation "org.springframework.security:spring-security-test"
  257. testImplementation "org.springframework.boot:spring-boot-test"
  258. testImplementation "com.tngtech.archunit:archunit-junit5-api:${archunitJunit5Version}"
  259. testRuntimeOnly "com.tngtech.archunit:archunit-junit5-engine:${archunitJunit5Version}"
  260. testImplementation "com.h2database:h2"
  261. developmentOnly "org.springframework.boot:spring-boot-devtools:${springBootVersion}"
  262. //jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
  263. compileOnly "org.projectlombok:lombok:1.18.24"
  264. annotationProcessor "org.projectlombok:lombok:1.18.24"
  265. implementation "com.querydsl:querydsl-core:5.0.0"
  266. implementation "com.querydsl:querydsl-jpa:5.0.0"
  267. annotationProcessor "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
  268. annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jpa"
  269. implementation "com.github.xiaoymin:knife4j-springdoc-ui:3.0.3"
  270. implementation "org.springframework.boot:spring-boot-starter-webflux"
  271. // https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-core
  272. implementation group: 'com.aliyun', name: 'aliyun-java-sdk-core', version: '4.5.18'
  273. //手动添加的依赖
  274. // https://mvnrepository.com/artifact/com.github.houbb/sensitive-word
  275. // implementation group: "com.github.houbb", name: "sensitive-word", version: "0.12.0"
  276. // https://mvnrepository.com/artifact/com.github.houbb/sensitive-word
  277. implementation "com.github.houbb:sensitive-word:0.12.0"
  278. //测试的 安装新的依赖时:先打包,然后提示失败,最下面有个红色的点击它,就会下载; 下载完成以后,在grad的菜单右键再刷新
  279. implementation "cn.hutool:hutool-crypto:5.8.18"
  280. }
  281. if (project.hasProperty("gae")) {
  282. task createPom {
  283. def basePath = 'build/resources/main/META-INF/maven'
  284. doLast {
  285. pom {
  286. withXml(dependencyManagement.pomConfigurer)
  287. }.writeTo("${basePath}/${project.group}/${project.name}/pom.xml")
  288. }
  289. }
  290. bootJar.dependsOn = [createPom]
  291. }
  292. task cleanResources(type: Delete) {
  293. delete "build/resources"
  294. }
  295. wrapper {
  296. gradleVersion = "7.4.2"
  297. }
  298. compileJava.dependsOn processResources
  299. processResources.dependsOn bootBuildInfo