mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
* build: Add xtask automation for binding version management Introduces a dedicated xtask crate that keeps language binding versions in sync with the core regorus crate, following the workflow pattern used by rust-analyzer, gitoxide, and ripgrep. Key features: - Git-based change detection: compares binding source files against a base ref (merge-base with origin/main by default) plus unstaged/ untracked files to identify which bindings have been modified - SemVer-aware bumping: binding edits trigger a minor version increment (e.g. 0.5.1 → 0.6.0) under pre-1.0 semantics, signaling potential breaking changes; clean bindings simply align to the root version - Multi-language support: updates Cargo manifests (Rust FFI, Java, Python, WASM, Ruby), Maven pom.xml (Java), Ruby version constants, and C# project files in a single pass - CI integration: --check mode fails fast when manifests are out of sync, ensuring pre-commit and release-plz workflows catch stale versions before merge Integration points: - release-plz.toml: runs cargo xtask bindings --base-ref origin/main after bumping the root crate, so binding versions are updated atomically during the release process - scripts/pre-commit: invokes cargo xtask bindings --check to block commits that would leave bindings out of sync - .cargo/config.toml: defines cargo xtask alias for convenience Documentation includes inline examples showing how version bumps behave when bindings are ahead/behind the root, and notes that the minor field acts as the major version under SemVer 0.y.z initial development phase. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com> * build: refresh xtask tooling, workflows, and locks - cargo xtask bindings: keep the binding version-sync pipeline intact - cargo xtask update-deps: new helper to regenerate workspace/binding Cargo.lock files - workflows: auto-detect the Java jar version in CI and temporarily disable the Ruby workflow - lock files: refresh root + binding snapshots after the dependency sweep Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com> --------- Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
70 lines
2.1 KiB
Markdown
70 lines
2.1 KiB
Markdown
# Regorus Java
|
|
<!-- Trivial change to trigger version bump test -->
|
|
**Regorus** is
|
|
|
|
- *Rego*-*Rus(t)* - A fast, light-weight [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/)
|
|
interpreter written in Rust.
|
|
- *Rigorous* - A rigorous enforcer of well-defined Rego semantics.
|
|
|
|
See main [Regorus page](https://github.com/microsoft/regorus) for more details about the project.
|
|
|
|
## Building
|
|
|
|
Due to operational overhead we don't publish Java bindings to Maven Central
|
|
currently (see https://github.com/microsoft/regorus/issues/237) and you need to build from source to use it.
|
|
|
|
In order to build Regorus Java for a target platform, you need to install Rust target for that platform first:
|
|
```bash
|
|
$ rustup target add aarch64-apple-darwin
|
|
```
|
|
|
|
Afterwards, you can build native library for that target using:
|
|
```bash
|
|
$ cargo build --release --target aarch64-apple-darwin
|
|
```
|
|
|
|
You will then have a native library at `target/aarch64-apple-darwin/release/libregorus_java.dylib` depending on your target.
|
|
|
|
You then need to build Java bindings using:
|
|
```bash
|
|
$ mvn package
|
|
```
|
|
|
|
And you will have a JAR at `./target/regorus-java-0.1.5.jar`.
|
|
|
|
## Usage
|
|
|
|
You can use Regorus Java bindings as:
|
|
|
|
```java
|
|
import com.microsoft.regorus.Engine;
|
|
|
|
public class Test {
|
|
public static void main(String[] args) {
|
|
try (Engine engine = new Engine()) {
|
|
engine.addPolicy(
|
|
"hello.rego",
|
|
"package test\nmessage = concat(\", \", [input.message, data.message])"
|
|
);
|
|
engine.addDataJson("{\"message\":\"World!\"}");
|
|
engine.setInputJson("{\"message\":\"Hello\"}");
|
|
String resJson = engine.evalQuery("data.test.message");
|
|
|
|
System.out.println(resJson);
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
You need to ensure artifacts built in [previous section](#building) are in Java's classpath.
|
|
|
|
For example with `java` CLI:
|
|
```bash
|
|
$ java -Djava.library.path=../../target/aarch64-apple-darwin/release/ -cp target/regorus-java-0.1.5.jar Test.java
|
|
```
|
|
|
|
should gave you the output:
|
|
```
|
|
{"result":[{"expressions":[{"value":"Hello, World!","text":"data.test.message","location":{"row":1,"col":1}}]}]}
|
|
```
|