-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
186 lines (163 loc) · 4.53 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
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
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin.Companion.METADATA_TARGET_NAME
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
import java.net.URI
buildscript {
repositories {
mavenCentral()
}
}
plugins {
kotlin("multiplatform").version("1.6.21")
id("org.jetbrains.kotlinx.benchmark") version "0.4.2"
`maven-publish`
`java-library`
jacoco
}
class Props {
fun String.toUpperSnakeCase() = this.replace("([a-z])([A-Z])".toRegex(), "$1_$2").toUpperCaseAsciiOnly()
operator fun getValue(self: Any?, prop: kotlin.reflect.KProperty<*>): String? =
project.findProperty(prop.name)?.toString() ?: System.getenv(prop.name.toUpperSnakeCase())
}
val forceVersion by Props()
project.group = "ru.spbstu"
project.version = forceVersion ?: "0.0.1.4"
repositories {
maven("https://maven.vorpal-research.science")
mavenCentral()
}
kotlin {
jvm {
compilations.all {
kotlinOptions.apply {
jvmTarget = "1.6"
}
}
}
js(IR) {
nodejs()
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
}
linuxX64()
targets.all {
if (name != METADATA_TARGET_NAME) compilations.maybeCreate("benchmarks")
}
sourceSets {
all {
languageSettings.apply {
optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalUnsignedTypes")
optIn("kotlin.ExperimentalStdlibApi")
}
}
val commonMain by getting {
dependencies {
implementation("ru.spbstu:kotlinx-warnings:${getKotlinPluginVersion()}")
}
}
val commonTest by getting {
dependsOn(commonMain)
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependsOn(commonMain)
}
val jvmTest by getting {
dependsOn(commonTest)
dependsOn(jvmMain)
dependencies {
api("org.jetbrains.kotlin:kotlin-test-junit")
implementation("com.google.guava:guava-testlib:18.0")
}
}
val jsMain by getting {
dependsOn(commonMain)
}
val jsTest by getting {
dependsOn(commonTest)
dependsOn(jsMain)
dependencies {
api(kotlin("test-js"))
}
}
val linuxX64Main by getting {
dependsOn(commonMain)
}
val linuxX64Test by getting {
dependsOn(linuxX64Main)
}
val commonBenchmarks by creating {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.2")
dependsOn(commonMain)
}
}
val jvmBenchmarks by getting {
dependsOn(jvmMain)
dependsOn(commonBenchmarks)
}
val jsBenchmarks by getting {
dependsOn(jsMain)
dependsOn(commonBenchmarks)
}
}
}
jacoco {
toolVersion = "0.8.6"
}
tasks.jacocoTestReport {
val coverageSourceDirs = arrayOf(
"src/commonMain",
"src/jvmMain"
)
val classFiles = File("${buildDir}/classes/kotlin/jvm/")
.walkBottomUp()
.toSet()
classDirectories.setFrom(classFiles)
sourceDirectories.setFrom(files(coverageSourceDirs))
executionData
.setFrom(files("${buildDir}/jacoco/jvmTest.exec"))
reports {
xml.isEnabled = true
html.isEnabled = true
}
}
val deployUsername by Props()
val deployPassword by Props()
benchmark {
configurations {
val main by getting {
mode = "avgt"
reportFormat = "scsv"
outputTimeUnit = "ns"
iterationTime = 1
iterations = 10
warmups = 8
}
}
targets {
kotlin.targets.all {
this.compilations.findByName("benchmarks")?.defaultSourceSetName?.let(::register)
}
}
}
publishing {
repositories {
maven {
url = URI("https://maven.pkg.github.com/vorpal-research/kotlin-maven")
credentials {
username = deployUsername
password = deployPassword
}
}
}
}