Skip to content

Commit

Permalink
Merge 'Add support for Java bindings' from Kim Seon Woo
Browse files Browse the repository at this point in the history
Purpose of this PR

- Add support for Java (as Java has an extensive community)
- Enable Limbo to be provided as a Java library in the future.

Changes

- Added `bindings/java` directory.
- Created `src` package for Java (Gradle) and `rs_src` for Rust JNI
code.
- Implemented basic functionality to gather feedback and proceed with
further development.
  - Some features just printout the result for testing purposes.

Future Work

- Integrate CI to publish the library.
- Enhance error handling mechanisms.
- Implement additional features and functionality.
- Add test code after we decide on which features to provide

Issue

#615

Closes #613
  • Loading branch information
penberg committed Jan 5, 2025
2 parents 1c2e074 + 370e1ca commit fdbf62d
Show file tree
Hide file tree
Showing 22 changed files with 1,253 additions and 0 deletions.
121 changes: 121 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[workspace]
resolver = "2"
members = [
"bindings/java",
"bindings/python",
"bindings/wasm",
"cli",
Expand Down
39 changes: 39 additions & 0 deletions bindings/java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
19 changes: 19 additions & 0 deletions bindings/java/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "java-limbo"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[lib]
name = "_limbo_java"
crate-type = ["cdylib"]
path = "rs_src/lib.rs"

[dependencies]
anyhow = "1.0"
limbo_core = { path = "../../core" }
jni = "0.21.1"
rand = { version = "0.8.5", features = [] }
lazy_static = "1.5.0"
7 changes: 7 additions & 0 deletions bindings/java/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
java_run: lib
export LIMBO_SYSTEM_PATH=../../target/debug && ./gradlew run

.PHONY: lib

lib:
cargo build
31 changes: 31 additions & 0 deletions bindings/java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
java
application
}

group = "org.github.tursodatabase"
version = "0.0.1-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
}

application {
mainClass.set("org.github.tursodatabase.Main")

val limboSystemLibraryPath = System.getenv("LIMBO_SYSTEM_PATH")
if (limboSystemLibraryPath != null) {
applicationDefaultJvmArgs = listOf(
"-Djava.library.path=${System.getProperty("java.library.path")}:$limboSystemLibraryPath"
)
}
}

tasks.test {
useJUnitPlatform()
}
Binary file added bindings/java/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions bindings/java/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit fdbf62d

Please sign in to comment.