Skip to content

Commit

Permalink
fix: support java #7
Browse files Browse the repository at this point in the history
  • Loading branch information
yankun1992 committed Jul 19, 2023
1 parent d8a5656 commit 4c78c99
Show file tree
Hide file tree
Showing 18 changed files with 2,153 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/test_java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test Java

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always
CONDA_PREFIX: /usr/share/miniconda

jobs:
test:
name: Build and test Java
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ "macos-latest", "windows-latest", "ubuntu-latest"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
echo $CONDA
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r build.requirements.txt
- name: Maturin develop
uses: PyO3/maturin-action@v1
with:
maturin-version: latest
command: develop
args: --release
- name: save bloom filter to file
run: python py_tests/test_save_file.py
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
- run: chmod +x millw
- run: ./millw fastbloomjvm.test
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ Cargo.lock
*.pyc

__pychche__

out
fastbloomjvm/native/target
fastbloomjvm/native/Cargo.lock
fastbloomjvm/native/.idea

.pytest_cache
.vscode
py_tests/.pytest_cache
data
1 change: 1 addition & 0 deletions .mill-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.10.12
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fastbloom_rs"
version = "0.5.4"
version = "0.5.5"
edition = "2021"
authors = ["Yan Kun <[email protected]>"]
description = "Some fast bloom filter implemented by Rust for Python and Rust! 10x faster than pybloom!"
Expand Down Expand Up @@ -39,6 +39,7 @@ rand = "0.8"

[workspace]
members = ["fastbloom-rs"]
exclude = ["fastbloomjvm/native"]

[[bench]]
name = "fastbloom"
Expand Down
54 changes: 54 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import mill._, scalalib._, publish._
import mill.define.Sources
import mill.scalalib.JavaModule
import $ivy.`io.github.otavia-projects::mill-rust_mill$MILL_BIN_PLATFORM:0.2.1`
import io.github.otavia.jni.plugin.RustJniModule

object ProjectInfo {

def description: String = "Some fast bloom filter implemented by Rust for Python and Java!"

def organization: String = "io.github.yankun1992"

def organizationUrl: String = ""

def projectUrl: String = ""

def licenses = Seq()

def author = Seq("Yan Kun <[email protected]>")

def version = "0.5.5-SNAPSHOT"

def buildTool = "mill"

def buildToolVersion = mill.BuildInfo.millVersion

}

object fastbloomjvm extends RustJniModule with PublishModule {

override def release: Boolean = true

override def publishVersion: T[String] = ProjectInfo.version

override def pomSettings: T[PomSettings] = PomSettings(
description = ProjectInfo.description,
organization = ProjectInfo.organization,
url = "",
licenses = ProjectInfo.licenses,
versionControl = VersionControl(),
developers = Seq(Developer("yan_kun", "Yan Kun", "", Some("icekredit"), Some("")))
)

override def artifactName = "fastbloomjvm"

override def artifactId = "fastbloom"

override def ivyDeps = Agg(ivy"io.github.otavia-projects:jni-loader:0.2.1")

object test extends Tests with TestModule.Junit4 {

}

}
2 changes: 1 addition & 1 deletion fastbloom-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fastbloom-rs"
version = "0.5.4"
version = "0.5.5"
edition = "2021"
authors = ["Yan Kun <[email protected]>"]
description = "Some fast bloom filter implemented by Rust for Python and Rust!"
Expand Down
12 changes: 12 additions & 0 deletions fastbloomjvm/native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "fastbloom" # generated by nativeInit with defaultNativeName
version = "0.5.5"
authors = ["Yan Kun <[email protected]>"]
edition = "2021"

[dependencies]
jni = "0.21"
fastbloom-rs = { path = "../../fastbloom-rs" }

[lib]
crate_type = ["cdylib"]
Loading

0 comments on commit 4c78c99

Please sign in to comment.