-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
89 lines (77 loc) · 2.73 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
plugins {
alias(libs.plugins.kotlin)
}
dependencies {
implementation(libs.kotlin.stdlib8)
implementation(libs.kotlin.reflect)
implementation(libs.selenium)
implementation(libs.log4j.iostreams)
implementation(libs.assertj)
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.log4j)
testRuntimeOnly(libs.log4j.slf4j)
testRuntimeOnly(libs.slf4j.jul)
}
java.toolchain.languageVersion.set(libs.versions.java.map(JavaLanguageVersion::of))
kotlin.jvmToolchain { languageVersion.set(libs.versions.java.map(JavaLanguageVersion::of)) }
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions {
verbose = true
allWarningsAsErrors = true
}
}
registerCopyLoggingFor(java.sourceSets["main"])
@Suppress("UnstableApiUsage")
testing.suites {
withType<JvmTestSuite>().configureEach {
registerCopyLoggingFor(sources)
useJUnitJupiter(libs.versions.junit)
targets.configureEach {
testTask.configure {
// Enable console logging.
testLogging { events("passed", "skipped", "failed") }
// Logging configuration.
jvmArgs("-Djava.util.logging.config.file=${rootProject.file("config/jul.properties")}")
// Share CI parameters with test.
exposePropertiesToTest(
"net.twisterrob.test.selenium.headless",
)
// Relocate Selenium Manager cache from ~/.cache/selenium to build directory.
// TODO currently in 4.10.0, it seems broken: https://github.com/SeleniumHQ/selenium/issues/12383
val driverCache = rootProject.layout.buildDirectory.dir("seleniummanager-cache")
outputs.dir(driverCache).withPropertyName("SE_CACHE_PATH")
environment("SE_CACHE_PATH", driverCache.get().asFile)
}
}
}
register<JvmTestSuite>("smokeTest") {
targets.configureEach {
testTask.configure {
options {
this as JUnitPlatformOptions
includeTags("smoke")
}
// Share classpath with test, don't use own.
val test = named<JvmTestSuite>("test")
testClassesDirs = files(test.map { it.sources.output.classesDirs })
classpath = files(test.map { it.sources.runtimeClasspath })
}
}
}
}
fun Test.exposePropertiesToTest(vararg propertyNames: String) {
val properties = propertyNames.associateWith { project.findProperty(it) }
properties.forEach { (name, value) -> inputs.property(name, value) }
properties.forEach { (name, value) -> value?.let { systemProperty(name, value) } }
}
fun Project.registerCopyLoggingFor(sourceSet: SourceSet) {
val copy = tasks.register<Copy>(sourceSet.getTaskName("copyLogging", "resources")) {
from(project.rootProject.file("config/log4j2.xml"))
into(sourceSet.resources.srcDirs.first())
}
tasks.named(sourceSet.processResourcesTaskName) {
dependsOn(copy)
}
}