diff --git a/build.gradle.kts b/build.gradle.kts index 464b3c0..4804a37 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("multiplatform") version "1.4-M2-mt" -// `maven-publish` + `maven-publish` } buildscript { @@ -17,7 +17,7 @@ buildscript { allprojects { group = "fr.acinq.secp256k1" - version = "0.2.1-1.4-M2" + version = "0.1.0-1.4-M2" repositories { jcenter() @@ -114,43 +114,47 @@ afterEvaluate { } } -//publishing { -// val snapshotName: String? by project -// 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" -// repositories { -// maven { -// name = "bintray" -// setUrl("https://api.bintray.com/maven/acinq/$btRepo/${project.name}/;publish=0") -// credentials { -// username = bintrayUsername -// password = bintrayApiKey -// } -// } -// } -// } -// -// publications.withType().configureEach { -// if (snapshotName != null && snapshotNumber != null) version = "${project.version}-${snapshotName}-${snapshotNumber}" -// 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") -// } -// } -// } -//} +allprojects { + plugins.withId("maven-publish") { + publishing { + val snapshotName: String? by project + 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" + repositories { + maven { + name = "bintray" + setUrl("https://api.bintray.com/maven/acinq/$btRepo/${project.name}/;publish=0") + credentials { + username = bintrayUsername + password = bintrayApiKey + } + } + } + } + + publications.withType().configureEach { + if (snapshotName != null && snapshotNumber != null) version = "${project.version}-${snapshotName}-${snapshotNumber}" + 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") + } + } + } + } + } +} diff --git a/jni/android/build.gradle.kts b/jni/android/build.gradle.kts index ee82311..e46fffe 100644 --- a/jni/android/build.gradle.kts +++ b/jni/android/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.library") kotlin("android") + `maven-publish` } kotlin { @@ -46,3 +47,20 @@ afterEvaluate { dependsOn(":native:buildSecp256k1Android") } } + +android { + afterEvaluate { + publishing { + publications { + create("android") { + artifactId = "secp256k1-jni-android" + from(components["release"]) + } +// create("androidDebug") { +// artifactId = "secp256k1-jni-android-debug" +// from(components["debug"]) +// } + } + } + } +} diff --git a/jni/build.gradle.kts b/jni/build.gradle.kts index 22b8072..e7565e8 100644 --- a/jni/build.gradle.kts +++ b/jni/build.gradle.kts @@ -1,5 +1,6 @@ plugins { kotlin("jvm") + `maven-publish` } val currentOs = org.gradle.internal.os.OperatingSystem.current() @@ -69,4 +70,13 @@ afterEvaluate { tasks["clean"].doLast { delete(buildDir.resolve("build/cmake")) } -} \ No newline at end of file +} + +publishing { + publications { + create("jvm") { + artifactId = "secp256k1-jni-common" + from(components["java"]) + } + } +} diff --git a/jni/jvm/build.gradle.kts b/jni/jvm/build.gradle.kts index 0684a1a..127098c 100644 --- a/jni/jvm/build.gradle.kts +++ b/jni/jvm/build.gradle.kts @@ -1,5 +1,6 @@ plugins { kotlin("jvm") + `maven-publish` } kotlin { @@ -12,10 +13,10 @@ dependencies { } val copyJni by tasks.creating(Sync::class) { - dependsOn(":native:buildSecp256k1Jvm") - from(rootDir.resolve("native/build/linux/libsecp256k1-jni.so")) { rename { "libsecp256k1-jni-linux-x86_64.so" } } - from(rootDir.resolve("native/build/darwin/libsecp256k1-jni.dylib")) { rename { "libsecp256k1-jni-darwin-x86_64.dylib" } } - from(rootDir.resolve("native/build/mingw/secp256k1-jni.dll")) { rename { "secp256k1-jni-mingw-x86_64.dll" } } + dependsOn(":jni:buildNativeJni") + from(rootDir.resolve("jni/build/jni/linux/libsecp256k1-jni.so")) { rename { "libsecp256k1-jni-linux-x86_64.so" } } + from(rootDir.resolve("jni/build/jni/darwin/libsecp256k1-jni.dylib")) { rename { "libsecp256k1-jni-darwin-x86_64.dylib" } } + from(rootDir.resolve("jni/build/jni/mingw/secp256k1-jni.dll")) { rename { "secp256k1-jni-mingw-x86_64.dll" } } into(buildDir.resolve("jniResources/fr/acinq/secp256k1/jni/native")) } @@ -23,3 +24,14 @@ val copyJni by tasks.creating(Sync::class) { dependsOn("copyJni") from(buildDir.resolve("jniResources")) } + +java.withSourcesJar() + +publishing { + publications { + create("jvm") { + artifactId = "secp256k1-jni-jvm" + from(components["java"]) + } + } +}