Skip to content

Commit 901a3d6

Browse files
committed
feat(android): add support for building Android AAR package
1 parent e5e9b15 commit 901a3d6

File tree

7 files changed

+108
-13
lines changed

7 files changed

+108
-13
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ jobs:
5252
- os: macos-15
5353
name: apple-xcframework
5454
make: xcframework
55+
- os: ubuntu-22.04
56+
name: android-aar
57+
make: aar
5558

5659
defaults:
5760
run:
@@ -231,19 +234,30 @@ jobs:
231234
for folder in "artifacts"/*; do
232235
if [ -d "$folder" ]; then
233236
name=$(basename "$folder")
234-
if [[ "$name" != "vector-apple-xcframework" ]]; then
237+
if [[ "$name" != "vector-apple-xcframework" && "$name" != "vector-android-aar" ]]; then
235238
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
236239
fi
237-
(cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .)
240+
if [[ "$name" != "vector-android-aar" ]]; then
241+
(cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .)
242+
else
243+
cp "$folder"/*.aar "${name}-${{ steps.tag.outputs.version }}.aar"
244+
fi
238245
fi
239246
done
240247
248+
- name: release android aar to maven central
249+
if: false # maven central namespace needs to be verified first steps.tag.outputs.version != ''
250+
run: cd packages/android && gradle publishReleasePublicationToOSSRHRepository -PVERSION=${{ steps.tag.outputs.version }}
251+
env:
252+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
253+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
254+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
255+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
256+
241257
- uses: softprops/[email protected]
242258
if: steps.tag.outputs.version != ''
243259
with:
244260
generate_release_notes: true
245261
tag_name: ${{ steps.tag.outputs.version }}
246-
files: |
247-
vector-*-${{ steps.tag.outputs.version }}.zip
248-
vector-*-${{ steps.tag.outputs.version }}.tar.gz
262+
files: vector-*-${{ steps.tag.outputs.version }}.*
249263
make_latest: true

.gitignore

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
.DS_Store
1+
# Build artifacts
2+
build/
3+
/dist
4+
.build
5+
*.a
6+
*.sqlite
7+
8+
# iOS/macOS
29
*.xcworkspacedata
310
*.xcuserstate
411
*.xcbkptlist
512
*.plist
6-
/build
7-
/dist
8-
*.sqlite
9-
*.a
13+
14+
# Android
15+
.gradle/
16+
*.aar
17+
local.properties
18+
jniLibs/
19+
*.apk
20+
*.ap_
21+
*.dex
22+
23+
# IDE
1024
.vscode
11-
.build
25+
.idea/
26+
*.iml
27+
28+
# System
29+
.DS_Store

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ $(DIST_DIR)/%.xcframework: $(LIB_NAMES)
178178

179179
xcframework: $(DIST_DIR)/vector.xcframework
180180

181+
aar:
182+
$(MAKE) clean && $(MAKE) PLATFORM=android ARCH=arm64-v8a
183+
mv $(DIST_DIR)/vector.so packages/android/src/main/jniLibs/arm64-v8a/
184+
$(MAKE) clean && $(MAKE) PLATFORM=android ARCH=x86_64
185+
mv $(DIST_DIR)/vector.so packages/android/src/main/jniLibs/x86_64/
186+
cd packages/android && gradle assembleRelease
187+
mv packages/android/build/outputs/aar/*.aar $(DIST_DIR)/vector.aar
188+
181189
version:
182190
@echo $(shell sed -n 's/^#define SQLITE_VECTOR_VERSION[[:space:]]*"\([^"]*\)".*/\1/p' src/sqlite-vector.h)
183191

@@ -201,5 +209,6 @@ help:
201209
@echo " test - Test the extension"
202210
@echo " help - Display this help message"
203211
@echo " xcframework - Build the Apple XCFramework"
212+
@echo " aar - Build the Android AAR package"
204213

205-
.PHONY: all clean test extension help version xcframework
214+
.PHONY: all clean test extension help version xcframework aar

packages/android/build.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath 'com.android.tools.build:gradle:8.5.2'
8+
}
9+
}
10+
11+
apply plugin: 'com.android.library'
12+
13+
android {
14+
namespace 'ai.sqlite.vector'
15+
compileSdk 34
16+
17+
defaultConfig {
18+
minSdk 26
19+
targetSdk 34
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
}
26+
}
27+
28+
compileOptions {
29+
sourceCompatibility JavaVersion.VERSION_1_8
30+
targetCompatibility JavaVersion.VERSION_1_8
31+
}
32+
33+
sourceSets {
34+
main {
35+
jniLibs.srcDirs = ['src/main/jniLibs']
36+
}
37+
}
38+
}
39+
40+
repositories {
41+
google()
42+
mavenCentral()
43+
maven { url 'https://jitpack.io' }
44+
}
45+
46+
dependencies {
47+
api 'com.github.requery:sqlite-android:3.49.0'
48+
}

packages/android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
2+
android.useAndroidX=true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>

src/sqlite-vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
extern "C" {
2525
#endif
2626

27-
#define SQLITE_VECTOR_VERSION "0.9.26"
27+
#define SQLITE_VECTOR_VERSION "0.9.27"
2828

2929
SQLITE_VECTOR_API int sqlite3_vector_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
3030

0 commit comments

Comments
 (0)