-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
157 lines (131 loc) · 4.33 KB
/
build.gradle.kts
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
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
plugins {
id("java")
id("com.github.spotbugs") version "6.0.25"
checkstyle
jacoco
id("info.solidsoft.pitest") version "1.15.0"
}
group = "nu.csse.sqe"
version = "1.0"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
// https://mvnrepository.com/artifact/org.easymock/easymock
testImplementation("org.easymock:easymock:5.4.0")
// cucumber
testImplementation(platform("io.cucumber:cucumber-bom:7.20.1"))
testImplementation("io.cucumber:cucumber-java")
testImplementation("io.cucumber:cucumber-junit-platform-engine")
testImplementation("io.cucumber:cucumber-picocontainer:7.20.1")
implementation("com.github.spotbugs:spotbugs-annotations:4.7.3")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
tasks.compileJava {
options.release = 11
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<Checkstyle>().configureEach {
reports {
xml.required = false
html.required = true
html.stylesheet = resources.text.fromFile("config/xsl/checkstyle-noframes-severity-sorted.xsl")
}
}
tasks.named<Checkstyle>("checkstyleMain") {
enabled = true
}
tasks.named<Checkstyle>("checkstyleTest") {
enabled = false
}
spotbugs {
ignoreFailures = false
showStackTraces = true
showProgress = true
effort = Effort.DEFAULT
reportLevel = Confidence.DEFAULT
// visitors = listOf("FindSqlInjection", "SwitchFallthrough")
// omitVisitors = listOf("FindNonShortCircuit")
reportsDir = layout.buildDirectory.dir("spotbugs").get().asFile
// includeFilter = file("include.xml")
// excludeFilter = file("exclude.xml")
// baselineFile = file("baseline.xml")
// onlyAnalyze = listOf("com.foobar.MyClass", "com.foobar.mypkg.*")
maxHeapSize = "1g"
extraArgs = listOf("-nested:false")
// jvmArgs = listOf("-Duser.language=ja")
}
checkstyle {
toolVersion = "10.18.2"
isIgnoreFailures = false
}
configurations {}
val cucumberRuntime by configurations.creating {
extendsFrom(configurations["testImplementation"])
}
task("cucumber") {
dependsOn("assemble", "compileTestJava")
doLast {
javaexec {
mainClass.set("io.cucumber.core.cli.Main")
classpath = cucumberRuntime + sourceSets.main.get().output + sourceSets.test.get().output
args = listOf("--plugin", "pretty",
"--glue", "explodingwildcats", // where the step definitions are.
"src/test/resources") // where the feature files are.
// Configure jacoco agent for the test coverage.
val jacocoAgent = zipTree(configurations.jacocoAgent.get().singleFile)
.filter { it.name == "jacocoagent.jar" }
.singleFile
jvmArgs = listOf("-javaagent:$jacocoAgent=destfile=$buildDir/results/jacoco/cucumber.exec,append=false")
}
}
}
tasks.spotbugsMain {
reports.create("html") {
required = true
outputLocation = layout.buildDirectory.file("reports/spotbugs/spotbugs.html")
setStylesheet("fancy-hist.xsl")
}
}
tasks.jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir("reports/jacoco")
}
}
tasks.build {
dependsOn("pitest")
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
finalizedBy(tasks.pitest)
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}
pitest {
targetClasses = setOf("explodingwildcats.*") //by default "${project.group}.*"
targetTests = setOf("explodingwildcats.*")
junit5PluginVersion = "1.2.1"
pitestVersion = "1.15.0" //not needed when a default PIT version should be used
threads = 4
outputFormats = setOf("HTML")
timestampedReports = false
testSourceSets.set(listOf(sourceSets.test.get()))
mainSourceSets.set(listOf(sourceSets.main.get()))
jvmArgs.set(listOf("-Xmx2048m"))
useClasspathFile.set(true) //useful with bigger projects on Windows
fileExtensionsToFilter.addAll("xml")
exportLineCoverage = true
}