-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
157 lines (135 loc) · 5.56 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import net.masterthought.cucumber.Configuration
import net.masterthought.cucumber.ReportBuilder
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "net.masterthought:cucumber-reporting:5.7.4"
}
}
plugins {
id 'org.springframework.boot' version '2.5.10'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.sonarqube' version '3.3'
id 'jacoco'
id 'java'
}
group = 'br.com.simple'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
jcenter()
}
ext {
set('swaggerVersion', "2.9.2")
set('springBootVersion', "2.5.10")
set('apacheCommonsVersion', "2.7")
set('apacheCommonsLangVersions', "2.6")
set('cucumberVersion', "7.5.0")
set('h2Version', "1.4.200")
set('cucumberReportingVersion', "5.7.4")
set('jacocoCoreVersion', "0.8.6")
set('jacocoReportVersion', "0.8.6")
}
dependencies {
// Spring Boot
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.data:spring-data-envers'
implementation 'org.springframework.boot:spring-boot-starter-validation'
// Swagger
implementation "io.springfox:springfox-swagger2:${swaggerVersion}"
implementation "io.springfox:springfox-swagger-ui:${swaggerVersion}"
implementation 'org.testng:testng:7.7.0'
// PostgreSQL
runtimeOnly 'org.postgresql:postgresql'
// Tests
testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
testImplementation "io.cucumber:cucumber-junit:${cucumberVersion}"
testImplementation "io.cucumber:cucumber-spring:${cucumberVersion}"
testImplementation "io.cucumber:cucumber-java:${cucumberVersion}"
testImplementation "com.h2database:h2:${h2Version}"
testImplementation "org.jacoco:org.jacoco.core:${jacocoCoreVersion}"
testImplementation "org.jacoco:org.jacoco.report:${jacocoReportVersion}"
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
// Apache Commons
implementation "commons-io:commons-io:${apacheCommonsVersion}"
implementation "commons-lang:commons-lang:${apacheCommonsLangVersions}"
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
//TODO: Ajustar o report cucumber + junit para o sonarclouddo, que está sendo sobreescrito um pelo outro quando useJunitPlatform() está habilitado
test {
useJUnitPlatform()
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
reports.html.destination = file("$buildDir/reports/tests")
reports.junitXml.destination = file("$buildDir/test-results")
}
task cucumber() {
dependsOn assemble, testClasses
doLast {
javaexec {
main = 'io.cucumber.core.cli.Main'
classpath = sourceSets.test.runtimeClasspath + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'json:build/cucumber/cucumber.json', 'src/test/resources/features']
}
}
//println("> debbugDir: ${project.buildDir}") //
//generateReport("${project.buildDir}/cucumber/cucumber.json", "${project.buildDir}/cucumber/cucumber-html-report")
}
jacocoTestReport.dependsOn processResources
tasks.jacocoTestReport {
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ["src/main/java/br/com/simple/crud/CrudApplication.java, " +
"src/main/java/br/com/simple/crud/config/**, " +
"src/main/java/br/com/simple/crud/exception/**, " +
"src/main/java/br/com/simple/crud/domain/dto/**, " +
"src/main/java/br/com/simple/crud/domain/entity/**"]
)
}))
}
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
}
test.finalizedBy jacocoTestReport
check.dependsOn test
check.dependsOn cucumber
sonarqube {
properties {
property "sonar.projectKey", "Caiuzu_crud"
property "sonar.organization", "caiuzu"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.junit.reportsPath", "${project.buildDir}/test-results"
property "sonar.cucumber.reportsPaths", "${project.buildDir}/cucumber/cucumber.json"
property "sonar.coverage.exclusions", "**/cucumber/**,"
property 'sonar.exclusions',
"src/main/java/br/com/simple/crud/CrudApplication.java," +
"src/main/java/br/com/simple/crud/config/**, " +
"src/main/java/br/com/simple/crud/exception/**, " +
"src/main/java/br/com/simple/crud/domain/dto/**, " +
"src/main/java/br/com/simple/crud/domain/entity/**"
}
}
static def generateReport(String pathCucumber, String pathReport) {
try {
File reportOutputDirectory = new File(pathReport)
List<String> jsonReportFiles = new ArrayList<>()
jsonReportFiles.add(pathCucumber)
String buildProjectName = "crud"
Configuration configuration = new Configuration(reportOutputDirectory, buildProjectName)
ReportBuilder reportBuilder = new ReportBuilder(jsonReportFiles, configuration)
reportBuilder.generateReports()
} catch (Exception ignored) {
}
}