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

Update README.md for Java bindings to mention we don't publish to Maven Central currently #246

Merged
merged 1 commit into from
May 20, 2024
Merged
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
76 changes: 24 additions & 52 deletions bindings/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,33 @@

See main [Regorus page](https://github.com/microsoft/regorus) for more details about the project.

## Usage
## Building

Regorus Java is published to Maven Central with native libraries for the following:
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.

- 64-bit Linux (kernel 3.2+, glibc 2.17+)
- ARM64 Linux (kernel 4.1, glibc 2.17+)
- 64-bit macOS (10.12+, Sierra+)
- ARM64 macOS (11.0+, Big Sur+)
- 64-bit MSVC (Windows 7+)
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
```

If you need to run it in a different OS or an architecture you need to manually [build it](#Building).
Afterwards, you can build native library for that target using:
```bash
$ cargo build --release --target aarch64-apple-darwin
```

If you're on one of the supported platforms, you can just pull prebuilt JAR from Maven Central by declaring a dependency on `com.microsoft.regorus:regorus-java`.
You will then have a native library at `../../target/aarch64-apple-darwin/release/libregorus_java.dylib` depending on your target.

With [Maven](https://maven.apache.org/):
```xml
<dependencies>
<dependency>
<groupId>com.microsoft.regorus</groupId>
<artifactId>regorus-java</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
You then need to build Java bindings using:
```bash
$ mvn package
```

With [Gradle](https://gradle.org/):
```kotlin
// build.gradle.kts
implementation("com.microsoft.regorus:regorus-java:0.0.1")
```
And you will have a JAR at `./target/regorus-java-0.0.1.jar`.

## Usage

Afterwards you can use it as follows:
You can use Regorus Java bindings as:

```java
import com.microsoft.regorus.Engine;
Expand All @@ -61,37 +56,14 @@ public class Test {
}
```

And you can see the following output once you run it:
```shell
{"result":[{"expressions":[{"value":"Hello, World!","text":"data.test.message","location":{"row":1,"col":1}}]}]}
```

## Building

In order to build Regorus Java for a target platform, you need to install Rust target
for that target 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 can then build a JAR from source using:
```bash
$ mvn package
```

And you will have a JAR at `./target/regorus-java-0.0.1.jar`.
You need to ensure artifacts built in [previous section](#building) are in Java's classpath.

You need to make sure both of the artifacts in Java's classpath.
For example with `java` CLI:
```bash
$ java -Djava.library.path=../../target/aarch64-apple-darwin/release/ -cp target/regorus-java-0.0.1.jar Test.java
```

should gave you the output:
```
{"result":[{"expressions":[{"value":"Hello, World!","text":"data.test.message","location":{"row":1,"col":1}}]}]}
```
Loading