Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-12576] Support publishing gradle to local maven repository #1076

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p ./sdk/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86}
cd "$(dirname "$0")"
mkdir -p ./sdk/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86}

Can we add this to the top of the file to make sure the script can be run from any directory?

I tend to run all the scripts from the root sdk dir like ./languages/kotlin/publish-local.sh if I can, and this would make it more convenient.


# 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
Loading