build.gradle 12 KB

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