1+ import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
2+ import org.gradle.api.tasks.testing.logging.TestLogEvent.*
3+ import java.io.Reader
4+ import java.util.*
5+
6+ plugins {
7+ java
8+ id(" org.springframework.boot" ) version " 3.1.0"
9+ id(" io.spring.dependency-management" ) version " 1.1.0"
10+ id(" com.diffplug.spotless" ) version " 6.18.0"
11+ id(" com.gorylenko.gradle-git-properties" ) version " 2.4.1"
12+ id(" org.owasp.dependencycheck" ) version " 8.2.1"
13+ jacoco
14+ id(" org.sonarqube" ) version " 4.0.0.2929"
15+ }
16+
17+ group = " com.example.graphql"
18+ version = " 0.0.1-SNAPSHOT"
19+ java.sourceCompatibility = JavaVersion .VERSION_17
20+
21+ configurations {
22+ compileOnly {
23+ extendsFrom(configurations.annotationProcessor.get())
24+ }
25+ }
26+
27+ repositories {
28+ mavenCentral()
29+ maven { url = uri(" https://repo.spring.io/milestone" ) }
30+ }
31+
32+ dependencies {
33+ implementation(" org.springframework.boot:spring-boot-starter-graphql" )
34+ implementation(" org.springframework.boot:spring-boot-starter-actuator" )
35+ implementation(" org.springframework.boot:spring-boot-starter-webflux" )
36+
37+ compileOnly(" org.projectlombok:lombok" )
38+ annotationProcessor(" org.projectlombok:lombok" )
39+ implementation(" org.springframework.boot:spring-boot-starter-data-r2dbc" )
40+ // Needed to run liquibase
41+ implementation(" org.springframework:spring-jdbc" )
42+ // Needed for pointcut
43+ implementation(" org.springframework.boot:spring-boot-starter-aop" )
44+
45+ runtimeOnly (" org.postgresql:r2dbc-postgresql" )
46+ runtimeOnly (" org.postgresql:postgresql" )
47+ implementation(" org.liquibase:liquibase-core" )
48+ implementation(" org.springdoc:springdoc-openapi-starter-webflux-ui:2.1.0" )
49+ implementation(" org.apache.commons:commons-lang3" )
50+
51+ testImplementation(" org.springframework.boot:spring-boot-starter-test" )
52+ testImplementation(" org.springframework.boot:spring-boot-testcontainers" )
53+ testImplementation(" io.projectreactor:reactor-test" )
54+ testImplementation(" org.projectlombok:lombok" )
55+ testImplementation(" org.awaitility:awaitility" )
56+ testImplementation(" org.testcontainers:junit-jupiter" )
57+ testImplementation(" org.testcontainers:postgresql" )
58+ testImplementation(" org.testcontainers:r2dbc" )
59+ testImplementation(" org.springframework.graphql:spring-graphql-test" )
60+ }
61+
62+ defaultTasks " bootRun"
63+
64+ springBoot {
65+ buildInfo()
66+ }
67+
68+ tasks.withType<Test > {
69+ useJUnitPlatform()
70+
71+ testLogging {
72+ events = setOf (PASSED , FAILED , SKIPPED )
73+ showStandardStreams = true
74+ exceptionFormat = FULL
75+ }
76+ finalizedBy(tasks.jacocoTestReport, tasks.jacocoTestCoverageVerification)
77+ }
78+
79+ jacoco {
80+ toolVersion = " 0.8.10"
81+ // reportsDirectory.set(layout.buildDirectory.dir("customJacocoReportDir"))
82+ }
83+
84+ tasks.jacocoTestReport {
85+ dependsOn(tasks.test)
86+ reports {
87+ xml.required.set(false )
88+ csv.required.set(false )
89+ html.outputLocation.set(layout.buildDirectory.dir(" reports/jacoco" ))
90+ }
91+ }
92+
93+ tasks.jacocoTestCoverageVerification {
94+ violationRules {
95+ rule {
96+ element = " BUNDLE"
97+ // includes = listOf("com.sivalabs.*")
98+
99+ limit {
100+ counter = " LINE"
101+ value = " COVEREDRATIO"
102+ minimum = " 0.63" .toBigDecimal()
103+ }
104+ }
105+ }
106+ }
107+
108+ gitProperties {
109+ failOnNoGitDirectory = false
110+ keys = listOf (" git.branch" ,
111+ " git.commit.id.abbrev" ,
112+ " git.commit.user.name" ,
113+ " git.commit.message.full" )
114+ }
115+
116+ spotless {
117+ java {
118+ importOrder()
119+ removeUnusedImports()
120+ palantirJavaFormat(" 2.30.0" )
121+ formatAnnotations()
122+ }
123+ }
124+
125+ // Reference doc : https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html
126+ dependencyCheck {
127+ // the default artifact types that will be analyzed.
128+ analyzedTypes = listOf (" jar" )
129+ // CI-tools usually needs XML-reports, but humans needs HTML.
130+ formats = listOf (" HTML" , " JUNIT" )
131+ // Specifies if the build should be failed if a CVSS score equal to or above a specified level is identified.
132+ // failBuildOnCVSS = 8.toFloat()
133+ // Output directory where the report should be generated
134+ outputDirectory = " $buildDir /reports/dependency-vulnerabilities"
135+ // specify a list of known issues which contain false-positives to be suppressed
136+ // suppressionFiles = ["$projectDir/config/dependencycheck/dependency-check-suppression.xml"]
137+ // Sets the number of hours to wait before checking for new updates from the NVD, defaults to 4.
138+ cveValidForHours = 24
139+ }
140+
141+ sonarqube {
142+ properties {
143+ property(" sonar.sourceEncoding" , " UTF-8" )
144+ property(" sonar.projectKey" , " rajadilipkolli_mfscreener" )
145+ property(" sonar.organization" , " rajadilipkolli" )
146+ property(" sonar.host.url" , " https://sonarcloud.io" )
147+ property(" sonar.sources" , " src/main/java" )
148+ property(" sonar.tests" , " src/test/java" )
149+ property(" sonar.exclusions" , " src/main/java/**/config/*.*,src/main/java/**/entities/*.*,src/main/java/**/models/*.*,src/main/java/**/exceptions/*.*,src/main/java/**/utils/*.*,src/main/java/**/*Application.*" )
150+ property(" sonar.test.inclusions" , " **/*Test.java,**/*IntegrationTest.java,**/*IT.java" )
151+ property(" sonar.java.codeCoveragePlugin" , " jacoco" )
152+ property(" sonar.coverage.jacoco.xmlReportPaths" , " $buildDir /jacoco/test/jacoco.xml" )
153+ property(" sonar.junit.reportPaths" , " $buildDir /test-results/test" )
154+ }
155+ }
0 commit comments