-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
70 lines (58 loc) · 1.9 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
import org.junit.platform.gradle.plugin.FiltersExtension
import org.junit.platform.gradle.plugin.JUnitPlatformExtension
plugins {
kotlin("jvm") version "1.1.51"
id("com.jfrog.bintray") version "1.8.0"
}
group = "ca.snasir"
version = "0.1.0"
buildscript {
dependencies {
classpath("org.junit.platform:junit-platform-gradle-plugin:1.0.0")
}
}
apply {
plugin("org.junit.platform.gradle.plugin")
from("groovy.gradle") // temporary until https://github.com/bintray/gradle-bintray-plugin/pull/194 is merged
}
configure<JUnitPlatformExtension> {
filters {
engines {
include("spek")
}
}
}
repositories {
jcenter()
}
dependencies {
compile(kotlin("stdlib"))
testCompile(kotlin("reflect"))
testCompile("org.junit.platform:junit-platform-runner:1.0.1")
testCompile("org.jetbrains.spek:spek-api:1.1.5")
testRuntime("org.jetbrains.spek:spek-junit-platform-engine:1.1.5")
testCompile("com.winterbe:expekt:0.2.0")
}
// temporary until https://github.com/bintray/gradle-bintray-plugin/pull/194 is merged
val bintrayPackage: groovy.lang.Closure<Any> by extra
bintray {
user = getConfig("bintrayUser")
key = getConfig("bintrayApiKey")
pkg(bintrayPackage)
}
fun getConfig(key: String): String {
val config = when {
project.hasProperty(key) -> project.property(key).toString()
else -> {
val envVarKey = key.replace(Regex("(.)(\\p{Upper})"), "$1_$2").toUpperCase()
System.getenv(envVarKey)
}
}
return config ?: error("Config key \"$key\" was not found in project properties provided or environment variables.")
}
fun JUnitPlatformExtension.filters(setup: FiltersExtension.() -> Unit) {
when (this) {
is ExtensionAware -> extensions.getByType(FiltersExtension::class.java).setup()
else -> throw Exception("${this::class} must be an instance of ExtensionAware")
}
}