-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.gradle.kts
224 lines (190 loc) · 6.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import org.jetbrains.dokka.Platform
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
plugins {
kotlin("multiplatform") version "1.9.23"
id("org.jetbrains.dokka") version "1.9.20"
`maven-publish`
}
val currentOs = org.gradle.internal.os.OperatingSystem.current()
group = "fr.acinq.bitcoin"
version = "0.21.0"
repositories {
google()
mavenCentral()
maven(url="https://oss.sonatype.org/content/repositories/snapshots/")
}
kotlin {
explicitApi()
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
linuxX64()
macosX64()
macosArm64()
iosX64 {
compilations["main"].cinterops.create("CoreCrypto")
}
iosArm64 {
compilations["main"].cinterops.create("CoreCrypto")
}
iosSimulatorArm64 {
compilations["main"].cinterops.create("CoreCrypto")
}
sourceSets {
val secp256k1KmpVersion = "0.16.0"
val commonMain by getting {
dependencies {
api("fr.acinq.secp256k1:secp256k1-kmp:$secp256k1KmpVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.5.4")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
val target = when {
currentOs.isLinux -> "linux"
currentOs.isMacOsX -> "darwin"
currentOs.isWindows -> "mingw"
else -> error("Unsupported OS $currentOs")
}
implementation("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm-$target:$secp256k1KmpVersion")
}
}
all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
}
// Configure all compilations of all targets:
targets.all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
// We use expect/actual for classes (see Chacha20Poly1305CipherFunctions). This feature is in beta and raises a warning.
// See https://youtrack.jetbrains.com/issue/KT-61573
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
}
}
}
}
configurations.forEach {
// do not cache changing (i.e. SNAPSHOT) dependencies
it.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
if (it.name.contains("testCompileClasspath")) {
it.attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, "java-runtime"))
}
}
// Disable cross compilation
plugins.withId("org.jetbrains.kotlin.multiplatform") {
afterEvaluate {
val currentOs = org.gradle.internal.os.OperatingSystem.current()
val targets = when {
currentOs.isLinux -> listOf()
else -> listOf("linuxX64")
}.mapNotNull { kotlin.targets.findByName(it) as? org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget }
configure(targets) {
compilations.all {
cinterops.all { tasks[interopProcessingTaskName].enabled = false }
compileTaskProvider.configure {
enabled = false
}
tasks[processResourcesTaskName].enabled = false
}
binaries.all { linkTask.enabled = false }
mavenPublication {
val publicationToDisable = this
tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != publicationToDisable } }
tasks.withType<GenerateModuleMetadata>().all { onlyIf { publication.get() != publicationToDisable } }
}
}
}
}
val dokkaOutputDir = layout.buildDirectory.dir("dokka")
tasks.dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
dokkaSourceSets {
configureEach {
val platformName = when (platform.get()) {
Platform.jvm -> "jvm"
Platform.js -> "js"
Platform.native -> "native"
Platform.common -> "common"
Platform.wasm -> "wasm"
else -> error("unexpected platform ${platform.get()}")
}
displayName.set(platformName)
perPackageOption {
matchingRegex.set(".*\\.internal.*") // will match all .internal packages and sub-packages
suppress.set(true)
}
}
}
}
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}
val javadocJar = tasks.create<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
from(dokkaOutputDir)
}
publishing {
publications.withType<MavenPublication>().configureEach {
version = project.version.toString()
artifact(javadocJar)
pom {
name.set("Kotlin Multiplatform Bitcoin Library")
description.set("A simple Kotlin Multiplatform library which implements most of the bitcoin protocol")
url.set("https://github.com/ACINQ/bitcoin-kmp")
licenses {
license {
name.set("Apache License v2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
issueManagement {
system.set("Github")
url.set("https://github.com/ACINQ/bitcoin-kmp/issues")
}
scm {
connection.set("https://github.com/ACINQ/bitcoin-kmp.git")
url.set("https://github.com/ACINQ/bitcoin-kmp")
}
developers {
developer {
name.set("ACINQ")
email.set("[email protected]")
}
}
}
}
}
afterEvaluate {
tasks.withType<AbstractTestTask> {
testLogging {
events("passed", "skipped", "failed", "standard_out", "standard_error")
showExceptions = true
showStackTraces = true
}
}
tasks.withType<KotlinJvmTest> {
environment("TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources"))
}
tasks.withType<KotlinNativeHostTest> {
environment("TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources"))
}
tasks.withType<KotlinNativeSimulatorTest> {
environment("SIMCTL_CHILD_TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources"))
}
}