Skip to content

Commit

Permalink
[PM-12576] Support publishing gradle to local maven repository (#1076)
Browse files Browse the repository at this point in the history
Support publishing to local maven repository.
  • Loading branch information
Hinton authored Sep 24, 2024
1 parent f62ed98 commit 0747621
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
16 changes: 16 additions & 0 deletions languages/kotlin/publish-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/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
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
36 changes: 19 additions & 17 deletions languages/kotlin/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0747621

Please sign in to comment.