-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
186 lines (166 loc) · 5.25 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.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.HostManager
import java.net.URI
plugins {
kotlin("multiplatform") version "1.4.20"
`maven-publish`
}
group = findProperty("group").toString()
version = findProperty("version").toString()
repositories {
mavenCentral()
jcenter()
maven {
url = URI("https://kotlin.bintray.com/kotlinx/")
}
}
base {
archivesBaseName = "todo-or-die"
}
kotlin {
jvm {
// fun jdkPath(version: Int): String {
// fun envOrProperty(name: String): String? = System.getenv(name) ?: findProperty(name) as String?
//
// return envOrProperty("JDK_$version") ?: version.takeIf { it < 9 }?.let { envOrProperty("JDK_1$version") }
// ?: error("Specify path to JDK $version in JDK_$version environment variable or Gradle property")
// }
//
// val JDK_8 by ext(jdkPath(8))
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
}
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
// jdkHome = JDK_8
}
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
js {
nodejs {}
compilations.all {
kotlinOptions {
sourceMap = true
moduleKind = "umd"
metaInfo = true
}
}
}
val nativeTarget = when {
HostManager.hostIsMac -> macosX64("macos")
HostManager.hostIsLinux -> linuxX64("linux")
HostManager.hostIsMingw -> mingwX64("mingw")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.1.1")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.0")
}
}
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
targets.withType<KotlinNativeTarget> {
named("${name}Main") {
kotlin.srcDir("src/nativeMain/kotlin")
resources.srcDir("src/nativeMain/resources")
}
named("${name}Test") {
kotlin.srcDir("src/nativeTest/kotlin")
resources.srcDir("src/nativeTest/resources")
}
}
}
}
publishing {
// https://github.com/gradle/gradle/issues/11412#issuecomment-555413327
System.setProperty("org.gradle.internal.publish.checksums.insecure", "true")
val vcs: String by project
val bintrayOrg: String by project
val bintrayRepository: String by project
val bintrayPackage: String by project
repositories {
maven {
name = "bintray"
url =
URI("https://api.bintray.com/maven/$bintrayOrg/$bintrayRepository/$bintrayPackage/;publish=0;override=0")
credentials {
username = findProperty("bintrayUser") as String?
password = findProperty("bintrayKey") as String?
}
}
}
publications {
val kotlinMultiplatform by getting
kotlinMultiplatform.closureOf<Publication> {
artifacts {
add(kotlinMultiplatform.name, "sources") {
builtBy("metadataSourcesJar")
}
}
}
}
publications.withType<MavenPublication> {
pom {
name.set(project.name)
description.set(project.description)
url.set(vcs)
licenses {
license {
name.set("MIT")
url.set("$vcs/blob/master/LICENCE.md")
distribution.set("repo")
}
}
developers {
developer {
id.set(bintrayOrg)
name.set("Sergii Prodan")
}
}
scm {
connection.set("$vcs.git")
developerConnection.set("$vcs.git")
url.set(vcs)
}
}
}
}
val taskPrefixes = when {
HostManager.hostIsLinux -> listOf(
"publishLinux",
"publishJs",
"publishJvm",
"publishMetadata",
"publishKotlinMultiplatform"
)
HostManager.hostIsMac -> listOf("publishMacos", "publishIos")
HostManager.hostIsMingw -> listOf("publishMingw")
else -> error("Unknown host, abort publishing.")
}
val publishTasks = tasks.withType<PublishToMavenRepository>().matching { task ->
taskPrefixes.any { task.name.startsWith(it) }
}
tasks.register("publishAll") { dependsOn(publishTasks) }