Update README.md for Java bindings to mention we don't publish to (#246)

Maven Central currently
This commit is contained in:
Burak
2024-05-20 17:15:39 +02:00
committed by GitHub
parent 209ece9dee
commit 25ac1b6c95

View File

@@ -8,38 +8,33 @@
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.0.1.jar`.
## Usage
Regorus Java is published to Maven Central with native libraries for the following:
- 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+)
If you need to run it in a different OS or an architecture you need to manually [build it](#Building).
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`.
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>
```
With [Gradle](https://gradle.org/):
```kotlin
// build.gradle.kts
implementation("com.microsoft.regorus:regorus-java:0.0.1")
```
Afterwards you can use it as follows:
You can use Regorus Java bindings as:
```java
import com.microsoft.regorus.Engine;
@@ -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}}]}]}
```
You need to ensure artifacts built in [previous section](#building) are in Java's classpath.
## 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 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}}]}]}
```