-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle.kts
202 lines (173 loc) · 5.98 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
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.dokka.Platform
plugins {
kotlin("multiplatform") version "1.9.22"
id("org.jetbrains.dokka") version "1.9.10"
`maven-publish`
}
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.10")
}
}
allprojects {
group = "fr.acinq.secp256k1"
version = "0.16.0"
repositories {
google()
mavenCentral()
}
}
val currentOs = OperatingSystem.current()
kotlin {
explicitApi()
val commonMain by sourceSets.getting
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
fun KotlinNativeTarget.secp256k1CInterop(target: String) {
compilations["main"].cinterops {
val libsecp256k1 by creating {
includeDirs.headerFilterOnly(project.file("native/secp256k1/include/"))
tasks[interopProcessingTaskName].dependsOn(":native:buildSecp256k1${target.capitalize()}")
}
}
}
val nativeMain by sourceSets.creating
linuxX64 {
secp256k1CInterop("host")
}
macosX64 {
secp256k1CInterop("host")
}
macosArm64 {
secp256k1CInterop("host")
}
iosX64 {
secp256k1CInterop("ios")
}
iosArm64 {
secp256k1CInterop("ios")
}
iosSimulatorArm64 {
secp256k1CInterop("ios")
}
sourceSets.all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
}
// Disable cross compilation
allprojects {
plugins.withId("org.jetbrains.kotlin.multiplatform") {
afterEvaluate {
val currentOs = OperatingSystem.current()
val targets = when {
currentOs.isLinux -> listOf()
currentOs.isMacOsX -> listOf("linuxX64")
currentOs.isWindows -> listOf("linuxX64")
else -> listOf("linuxX64")
}.mapNotNull { kotlin.targets.findByName(it) as? KotlinNativeTarget }
configure(targets) {
compilations.all {
cinterops.all { tasks[interopProcessingTaskName].enabled = false }
compileKotlinTask.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 } }
}
}
}
}
}
allprojects {
val javadocJar = tasks.create<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Publication
plugins.withId("maven-publish") {
publishing {
publications.withType<MavenPublication>().configureEach {
version = project.version.toString()
artifact(javadocJar)
pom {
name.set("secp256k1 for Kotlin/Multiplatform")
description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux")
url.set("https://github.com/ACINQ/secp256k1-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/secp256k1-kmp/issues")
}
scm {
connection.set("https://github.com/ACINQ/secp256k1-kmp.git")
url.set("https://github.com/ACINQ/secp256k1-kmp")
}
developers {
developer {
name.set("ACINQ")
email.set("hello@acinq.co")
}
}
}
}
}
}
if (project.name !in listOf("native", "tests")) {
afterEvaluate {
val dokkaOutputDir = buildDir.resolve("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"
}
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)
}
javadocJar.dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
javadocJar.from(dokkaOutputDir)
}
}
}
allprojects {
afterEvaluate {
tasks.withType<AbstractTestTask>() {
testLogging {
events("passed", "skipped", "failed", "standard_out", "standard_error")
showExceptions = true
showStackTraces = true
}
}
}
}