kotlin-bip39/bip39-lib/build.gradle.kts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

197 lines
6.1 KiB
Plaintext
Raw Normal View History

2022-07-18 05:06:48 -07:00
import java.util.Base64
2022-04-21 05:16:24 -07:00
plugins {
2023-05-18 06:25:19 -07:00
// https://github.com/gradle/gradle/issues/20084#issuecomment-1060822638
id(libs.plugins.kotlin.multiplatform.get().pluginId)
2022-04-21 07:16:42 -07:00
alias(libs.plugins.dokka)
2023-02-10 08:08:17 -08:00
alias(libs.plugins.kotest)
2022-04-26 05:08:28 -07:00
id("bip39.kotlin-multiplatform-conventions")
id("bip39.dependency-conventions")
2023-05-18 06:25:19 -07:00
// https://github.com/gradle/gradle/issues/20084#issuecomment-1060822638
id(libs.plugins.kotlinx.kover.get().pluginId)
id("bip39.coverage-conventions")
2022-07-18 05:06:48 -07:00
id("maven-publish")
id("signing")
}
2022-04-21 05:16:24 -07:00
2023-02-10 08:08:17 -08:00
val enableNative = project.property("NATIVE_TARGETS_ENABLED").toString().toBoolean()
val nativeTargets = if (enableNative) arrayOf(
"linuxX64",
"macosX64", "macosArm64",
"iosArm64", "iosX64", "iosSimulatorArm64",
"tvosArm64", "tvosX64", "tvosSimulatorArm64",
"watchosArm32", "watchosArm64", "watchosX64", "watchosSimulatorArm64",
"mingwX64"
) else arrayOf()
kotlin {
2022-04-26 05:08:28 -07:00
jvm {
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
2023-02-10 08:08:17 -08:00
for (target in nativeTargets) {
targets.add(presets.getByName(target).createTarget(target))
}
2022-07-18 05:06:48 -07:00
sourceSets {
val commonMain by getting {
dependencies {
}
2022-04-21 07:37:58 -07:00
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotest.framework.engine)
implementation(libs.kotest.assertion)
implementation(libs.kotest.property)
}
}
@Suppress("UnusedPrivateProperty")
val jvmMain by getting {
dependencies {
}
}
@Suppress("UnusedPrivateProperty")
val jvmTest by getting {
dependencies {
implementation(libs.kotest.runner.junit5)
}
2022-04-21 07:37:58 -07:00
}
2023-02-10 08:08:17 -08:00
if (enableNative) {
val nonJvmMain by creating {
dependsOn(commonMain)
dependencies {
implementation(libs.com.squareup.okio)
}
}
val mingwMain by creating {
dependsOn(nonJvmMain)
}
val unixMain by creating {
dependsOn(nonJvmMain)
}
for (target in nativeTargets) {
when (target) {
"mingwX64" ->
getByName("${target}Main").dependsOn(mingwMain)
else ->
getByName("${target}Main").dependsOn(unixMain)
}
getByName("${target}Test").dependsOn(commonTest)
}
}
2022-04-21 07:37:58 -07:00
}
}
2022-07-18 05:06:48 -07:00
tasks {
2023-08-31 01:11:17 -07:00
val dokkaOutputDir = layout.buildDirectory.dir("dokka").get().asFile
2022-07-18 05:06:48 -07:00
dokkaHtml.configure {
outputDirectory.set(dokkaOutputDir)
}
val deleteDokkaOutputDir = register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}
register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
}
val publicationVariant = "release"
val myVersion = project.property("LIBRARY_VERSION").toString()
val myArtifactId = "kotlin-bip39"
val isSnapshot = project.property("IS_SNAPSHOT").toString().toBoolean()
publishing {
publications {
withType<MavenPublication> {
artifact(tasks.getByName("javadocJar"))
// Artifact id is tricky. Gradle uses the project name by default, but Kotlin multiplatform needs to add
// platform specific suffixes. Doing a partial replacement is the way to rename the artifact.
artifactId = artifactId.replace(project.name, myArtifactId)
2022-07-18 05:06:48 -07:00
groupId = "cash.z.ecc.android"
version = if (isSnapshot) {
"$myVersion-SNAPSHOT"
} else {
myVersion
}
pom {
name.set("Kotlin BIP-39")
description.set("A concise implementation of BIP-0039 in Kotlin.")
url.set("https://github.com/zcash/kotlin-bip39/")
inceptionYear.set("2020")
scm {
url.set("https://github.com/zcash/kotlin-bip39/")
connection.set("scm:git:git://github.com/zcash/kotlin-bip39.git")
developerConnection.set("scm:git:ssh://git@github.com/zcash/kotlin-bip39.git")
}
developers {
developer {
id.set("zcash")
name.set("Zcash")
url.set("https://github.com/zcash/")
}
}
licenses {
license {
name.set("The MIT License")
url.set("https://opensource.org/licenses/MIT")
distribution.set("repo")
}
}
}
}
}
repositories {
val mavenUrl = if (isSnapshot) {
project.property("ZCASH_MAVEN_PUBLISH_SNAPSHOT_URL").toString()
} else {
project.property("ZCASH_MAVEN_PUBLISH_RELEASE_URL").toString()
}
val mavenPublishUsername = project.property("ZCASH_MAVEN_PUBLISH_USERNAME").toString()
val mavenPublishPassword = project.property("ZCASH_MAVEN_PUBLISH_PASSWORD").toString()
mavenLocal {
name = "MavenLocal"
}
maven(mavenUrl) {
name = "MavenCentral"
credentials {
username = mavenPublishUsername
password = mavenPublishPassword
}
}
}
}
signing {
// Maven Central requires signing for non-snapshots
isRequired = !isSnapshot
2022-07-18 05:06:48 -07:00
val signingKey = run {
val base64EncodedKey = project.property("ZCASH_ASCII_GPG_KEY").toString()
if (base64EncodedKey.isNotEmpty()) {
val keyBytes = Base64.getDecoder().decode(base64EncodedKey)
String(keyBytes)
} else {
""
}
}
if (signingKey.isNotEmpty()) {
useInMemoryPgpKeys(signingKey, "")
}
sign(publishing.publications)
}