From 604eb15ebefcdff4ed6754868ab377e930ef8da5 Mon Sep 17 00:00:00 2001 From: Hinton Date: Tue, 24 Sep 2024 12:21:27 +0200 Subject: [PATCH 1/2] Support publishing gradle to local maven repository --- languages/kotlin/publish-local.sh | 11 ++++++++++ languages/kotlin/sdk/build.gradle | 36 ++++++++++++++++--------------- 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100755 languages/kotlin/publish-local.sh diff --git a/languages/kotlin/publish-local.sh b/languages/kotlin/publish-local.sh new file mode 100755 index 000000000..606b2ff40 --- /dev/null +++ b/languages/kotlin/publish-local.sh @@ -0,0 +1,11 @@ +mkdir -p ./sdk/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86} + +# Build arm64 for emulator +cross build -p bitwarden-uniffi --release --target=aarch64-linux-android +mv ../../target/aarch64-linux-android/release/libbitwarden_uniffi.so ./sdk/src/main/jniLibs/arm64-v8a/libbitwarden_uniffi.so + +# Generate latest bindings +./build-schemas.sh + +# Publish to local maven +./gradlew sdk:publishToMavenLocal -Pversion=LOCAL diff --git a/languages/kotlin/sdk/build.gradle b/languages/kotlin/sdk/build.gradle index d3ea098e3..2006e4673 100644 --- a/languages/kotlin/sdk/build.gradle +++ b/languages/kotlin/sdk/build.gradle @@ -47,23 +47,25 @@ publishing { groupId = 'com.bitwarden' artifactId = 'sdk-android' - // Determine the version from the git history. - // - // PRs: use the branch name. - // Main: Grab it from `crates/bitwarden/Cargo.toml` - - def branchName = 'git branch --show-current'.execute().text.trim() - - if (branchName == 'main') { - def content = ['grep', '-o', '^version = ".*"', '../../Cargo.toml'].execute().text.trim() - def match = ~/version = "(.*)"/ - def matcher = match.matcher(content) - matcher.find() - - version = "${matcher.group(1)}-SNAPSHOT" - } else { - // branchName-SNAPSHOT - version = "${branchName.replaceAll('/', '-')}-SNAPSHOT" + if (findProperty('version') == 'unspecified') { + // Determine the version from the git history. + // + // PRs: use the branch name. + // Main: Grab it from `crates/bitwarden/Cargo.toml` + + def branchName = 'git branch --show-current'.execute().text.trim() + + if (branchName == 'main') { + def content = ['grep', '-o', '^version = ".*"', '../../Cargo.toml'].execute().text.trim() + def match = ~/version = "(.*)"/ + def matcher = match.matcher(content) + matcher.find() + + version = "${matcher.group(1)}-SNAPSHOT" + } else { + // branchName-SNAPSHOT + version = "${branchName.replaceAll('/', '-')}-SNAPSHOT" + } } afterEvaluate { From 997570dbfec1443b5db8f060604f57119d1e11ac Mon Sep 17 00:00:00 2001 From: Hinton Date: Tue, 24 Sep 2024 13:19:19 +0200 Subject: [PATCH 2/2] Tweak bash script --- languages/kotlin/publish-local.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/languages/kotlin/publish-local.sh b/languages/kotlin/publish-local.sh index 606b2ff40..68e67455f 100755 --- a/languages/kotlin/publish-local.sh +++ b/languages/kotlin/publish-local.sh @@ -1,3 +1,8 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$0")" + mkdir -p ./sdk/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86} # Build arm64 for emulator