Skip to content

Commit

Permalink
Support publishing gradle to local maven repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Sep 24, 2024
1 parent 56fc75d commit 604eb15
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
11 changes: 11 additions & 0 deletions languages/kotlin/publish-local.sh
Original file line number Diff line number Diff line change
@@ -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
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 604eb15

Please sign in to comment.