2020-06-26 13:48:50 +02:00
|
|
|
plugins {
|
2020-07-06 21:45:17 +02:00
|
|
|
kotlin("multiplatform") version "1.4-M3"
|
2020-07-02 11:39:42 +02:00
|
|
|
`maven-publish`
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
|
2020-07-01 12:15:04 +02:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
classpath("com.android.tools.build:gradle:4.0.0")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
group = "fr.acinq.secp256k1"
|
2020-07-06 21:45:17 +02:00
|
|
|
version = "0.1.0-1.4-M3"
|
2020-07-01 12:15:04 +02:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
google()
|
|
|
|
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
|
|
|
|
}
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val currentOs = org.gradle.internal.os.OperatingSystem.current()
|
|
|
|
|
|
|
|
kotlin {
|
|
|
|
explicitApi()
|
|
|
|
|
2020-06-26 17:10:48 +02:00
|
|
|
val commonMain by sourceSets.getting {
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("stdlib-common"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-26 13:48:50 +02:00
|
|
|
jvm {
|
|
|
|
compilations.all {
|
|
|
|
kotlinOptions.jvmTarget = "1.8"
|
|
|
|
}
|
2020-07-01 12:15:04 +02:00
|
|
|
compilations["main"].dependencies {
|
|
|
|
implementation(kotlin("stdlib-jdk8"))
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
2020-06-26 17:10:48 +02:00
|
|
|
}
|
|
|
|
|
2020-07-01 12:15:04 +02:00
|
|
|
fun org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.secp256k1CInterop(target: String) {
|
2020-06-26 17:10:48 +02:00
|
|
|
compilations["main"].cinterops {
|
|
|
|
val libsecp256k1 by creating {
|
|
|
|
includeDirs.headerFilterOnly(project.file("native/secp256k1/include/"))
|
2020-07-01 12:15:04 +02:00
|
|
|
tasks[interopProcessingTaskName].dependsOn(":native:buildSecp256k1${target.capitalize()}")
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-26 17:10:48 +02:00
|
|
|
|
|
|
|
val nativeMain by sourceSets.creating { dependsOn(commonMain) }
|
|
|
|
|
2020-07-01 12:15:04 +02:00
|
|
|
linuxX64("linux") {
|
|
|
|
secp256k1CInterop("linux")
|
2020-06-26 17:10:48 +02:00
|
|
|
// https://youtrack.jetbrains.com/issue/KT-39396
|
|
|
|
compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/linux/libsecp256k1.a")
|
|
|
|
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
|
|
|
|
}
|
|
|
|
|
|
|
|
ios {
|
2020-07-01 12:15:04 +02:00
|
|
|
secp256k1CInterop("ios")
|
2020-06-26 17:10:48 +02:00
|
|
|
// https://youtrack.jetbrains.com/issue/KT-39396
|
|
|
|
compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/native/build/ios/libsecp256k1.a")
|
|
|
|
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets.all {
|
|
|
|
languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
|
|
|
|
}
|
|
|
|
|
2020-06-26 13:48:50 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 13:02:45 +02:00
|
|
|
// Disable cross compilation
|
2020-07-02 12:19:29 +02:00
|
|
|
allprojects {
|
|
|
|
plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
|
|
|
afterEvaluate {
|
|
|
|
val currentOs = org.gradle.internal.os.OperatingSystem.current()
|
|
|
|
val targets = when {
|
|
|
|
currentOs.isLinux -> listOf()
|
|
|
|
currentOs.isMacOsX -> listOf("linux")
|
|
|
|
currentOs.isWindows -> listOf("linux")
|
|
|
|
else -> listOf("linux")
|
|
|
|
}.mapNotNull { kotlin.targets.findByName(it) as? org.jetbrains.kotlin.gradle.plugin.mpp.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 } }
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 13:02:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-02 11:39:42 +02:00
|
|
|
allprojects {
|
|
|
|
plugins.withId("maven-publish") {
|
|
|
|
publishing {
|
|
|
|
val snapshotNumber: String? by project
|
|
|
|
|
|
|
|
val bintrayUsername: String? = (properties["bintrayUsername"] as String?) ?: System.getenv("BINTRAY_USER")
|
|
|
|
val bintrayApiKey: String? = (properties["bintrayApiKey"] as String?) ?: System.getenv("BINTRAY_APIKEY")
|
|
|
|
if (bintrayUsername == null || bintrayApiKey == null) logger.warn("Skipping bintray configuration as bintrayUsername or bintrayApiKey is not defined")
|
|
|
|
else {
|
|
|
|
val btRepo = if (snapshotNumber != null) "snapshots" else "libs"
|
2020-07-06 11:37:10 +02:00
|
|
|
val btPublish = if (snapshotNumber != null) "1" else "0"
|
2020-07-02 11:39:42 +02:00
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = "bintray"
|
2020-07-06 11:37:10 +02:00
|
|
|
setUrl("https://api.bintray.com/maven/acinq/$btRepo/${rootProject.name}/;publish=$btPublish")
|
2020-07-02 11:39:42 +02:00
|
|
|
credentials {
|
|
|
|
username = bintrayUsername
|
|
|
|
password = bintrayApiKey
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-03 19:12:38 +02:00
|
|
|
val gitRef: String? by project
|
|
|
|
val gitSha: String? by project
|
|
|
|
val eapBranch = gitRef?.split("/")?.last() ?: "dev"
|
|
|
|
val eapSuffix = gitSha?.let { "-${it.substring(0, 7)}" } ?: ""
|
2020-07-02 11:39:42 +02:00
|
|
|
publications.withType<MavenPublication>().configureEach {
|
2020-07-03 19:12:38 +02:00
|
|
|
if (snapshotNumber != null) version = "${project.version}-$eapBranch-$snapshotNumber$eapSuffix"
|
2020-07-02 11:39:42 +02:00
|
|
|
pom {
|
|
|
|
description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux")
|
|
|
|
url.set("https://github.com/ACINQ/secp256k1-kmp")
|
|
|
|
licenses {
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|