generated from hiberbee/template-java-cucumber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
187 lines (169 loc) · 5.96 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
plugins {
id("java-library")
id("com.github.ben-manes.versions") version "0.29.0" apply(false)
id("org.jetbrains.gradle.plugin.idea-ext") version "0.8.1" apply(false)
id("org.sonarqube") version "3.0" apply(false)
}
def VERSIONS = [
assertj : "3.17.0",
cucumber : "6.10.1",
junit : "5.7.0-RC1",
guava : "29.0-jre",
springBoot : "2.3.3.RELEASE",
kubernetesAssertions: "4.0.0",
kubernetesClient : "4.10.3",
]
def organization = "hiberbee"
group "dev.${organization}"
version "1.0.0"
if (!System.getenv().hasProperty("CI") || !System.getenv("CI")) {
apply plugin: "idea"
apply plugin: "jacoco"
apply plugin: "org.jetbrains.gradle.plugin.idea-ext"
apply plugin: "org.sonarqube"
apply plugin: "com.github.ben-manes.versions"
tasks {
dependencyUpdates {
checkConstraints true
}
idea {
project {
settings {
copyright {
useDefault = "MIT"
profiles {
MIT {
notice = file("LICENSE").readLines().join("\n")
}
}
}
}
}
module {
outputDir project.buildDir
downloadJavadoc false
downloadSources true
inheritOutputDirs true
excludeDirs += files(".gradle", ".idea", ".scannerwork", "gradle")
generatedSourceDirs += files(
"${project.buildDir}/generated/sources/annotationProcessor/java/main",
"${project.buildDir}/generated/sources/annotationProcessor/java/test"
)
}
}
sonarqube {
properties {
property "sonar.login", System.getenv("SONAR_TOKEN")
property "sonar.organization", organization
property "sonar.projectKey", project.name
property "sonar.projectName", project.name
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.scm.provider", "git"
property "sonar.branch.name", "latest"
property "sonar.java.binaries", "${project.buildDir}/libs"
property "sonar.java.libraries", "${project.buildDir}/classes/java/main"
property "sonar.java.test.libraries", "${project.buildDir}/classes/java/test"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/*.xml"
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled true
html.destination file("${project.buildDir}/reports/jacoco")
}
}
test {
jacoco {
enabled true
dumpOnExit true
}
finalizedBy tasks.getByName("jacocoTestReport")
}
}
}
class CucumberTask extends JavaExec {
@Input
CucumberTask withTags(String... tags) {
tags.each { args += ["--include-tag", it] }
return this
}
@Input
CucumberTask withoutTags(String... tags) {
tags.each { args += ["--exclude-tag", it] }
return this
}
@Input
CucumberTask withDirectories(String... name) {
name.each { args += ["--select-directory", it] }
return this
}
@Input
CucumberTask withProperties(Map properties) {
properties.each { jvmArgs += "-D${it.key}=${it.value}" }
return this
}
CucumberTask() {
group "cucumber"
dependsOn project.tasks.getByName("build"), project.tasks.getByName("testClasses")
outputs.dir "${project.buildDir}/reports"
main "org.junit.platform.console.ConsoleLauncher"
classpath project.convention.getPlugin(JavaPluginConvention.class).sourceSets.findByName("test").runtimeClasspath
args "--include-engine", "cucumber", "--reports-dir", "${project.buildDir}/reports"
}
}
dependencyLocking {
lockAllConfigurations()
lockFile = file("${projectDir}/gradle.lockfile")
}
tasks {
compileJava {
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14
options.fork = true
options.warnings = false
options.incremental = true
dependsOn tasks.getByName("processResources")
}
test {
useJUnitPlatform {
failFast true
}
scanForTestClasses false
}
}
String[] featureDirs = System.getenv().hasProperty("FEATURES_DIR")
? System.getenv("FEATURES_DIR").split(":")
: ["${project.buildDir}/resources/test/${project.group.toString().replace('.', '/')}/features"]
tasks.register("features", CucumberTask) {
// it.withTags(java.util.Optional.ofNullable(System.getProperty("tags.include")).map(it->it.split(","))
// it.withoutTags(System.getProperty("tags.exclude", "").split(","))
it.withDirectories(featureDirs)
// it.
// withProperties(System.getProperty("properties", "").split(",").collectEntries { entry -> Map.entry(entry.split("=")[0], entry.split("=")[1]) })
}
repositories {
mavenCentral()
}
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:$VERSIONS.springBoot")
annotationProcessor platform("org.springframework.boot:spring-boot-dependencies:$VERSIONS.springBoot")
implementation platform("io.cucumber:cucumber-core:$VERSIONS.cucumber")
testImplementation platform("org.junit:junit-bom:$VERSIONS.junit")
testRuntimeOnly platform("org.junit:junit-bom:$VERSIONS.junit")
implementation("com.google.guava:guava:$VERSIONS.guava")
implementation("io.cucumber:cucumber-java")
implementation("io.cucumber:cucumber-spring")
implementation("io.fabric8:kubernetes-assertions:$VERSIONS.kubernetesAssertions")
implementation("io.fabric8:kubernetes-client:$VERSIONS.kubernetesClient")
implementation("org.assertj:assertj-core:$VERSIONS.assertj")
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("io.cucumber:cucumber-junit-platform-engine")
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-console")
testRuntimeOnly("org.junit.platform:junit-platform-runner")
annotationProcessor("org.projectlombok:lombok")
}