Skip to content

Commit f381ba3

Browse files
authored
build: set up and test GraalPy (#7)
* docs: update README badge Signed-off-by: Cesar Berrospi Ramis <[email protected]> * build: set up and test GraalPy Signed-off-by: Cesar Berrospi Ramis <[email protected]> --------- Signed-off-by: Cesar Berrospi Ramis <[email protected]>
1 parent 8a18685 commit f381ba3

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: actions/setup-java@v4
2828
with:
2929
java-version: ${{matrix.java-version}}
30-
distribution: 'adopt'
30+
distribution: 'graalvm'
3131
cache: 'maven'
3232
- name: Build & Test
3333
run: mvn -B clean package

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![License MIT](https://img.shields.io/github/license/docling-project/docling-parse)](https://opensource.org/licenses/MIT)
2-
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
2+
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
3+
[![graalpy](https://img.shields.io/badge/pyenv-graalpy-blue)](#start-replacing-cpython-with-graalpy)
34

45

56
# Docling4j version 0.1.1
@@ -22,6 +23,8 @@ for the service, like this:
2223
</dependency>
2324
```
2425

26+
**docling4j** uses [GraalPy](https://www.graalvm.org/python), a high-performance embeddable Python 3 runtime for Java. Although not required, [Oracle GraalVM JDK](https://www.oracle.com/java/graalvm/) is recommended for running **docling4j**, since it supports runtime compilation to native code and efficient execution of embedded applications. Find more details on the level of optimizations of different Java runtimes [here](https://www.graalvm.org/latest/reference-manual/embed-languages/#runtime-optimization-support).
27+
2528
## Get help and support
2629

2730
Please feel free to connect with us using the [discussion section](https://github.com/docling-project/docling/discussions).

pom.xml

+7-11
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.source>21</maven.compiler.source>
15+
<maven.compiler.target>21</maven.compiler.target>
1416
<surefire-version>3.1.2</surefire-version>
15-
<checkstyle-plugin-version>3.3.0</checkstyle-plugin-version>
17+
<checkstyle-plugin-version>3.6.0</checkstyle-plugin-version>
1618
<checkstyle-version>10.21.4</checkstyle-version>
17-
<jacoco-plugin-version>0.8.10</jacoco-plugin-version>
19+
<jacoco-plugin-version>0.8.12</jacoco-plugin-version>
1820
<compiler-plugin-version>3.14.0</compiler-plugin-version>
19-
<java-source-version>21</java-source-version>
20-
<java-target-version>21</java-target-version>
2121
<maven-enforcer-version>3.4.1</maven-enforcer-version>
2222
<maven-deploy-plugin-version>3.1.1</maven-deploy-plugin-version>
2323
<min-maven-version>3.5.0</min-maven-version>
@@ -89,9 +89,9 @@
8989
<version>24.2.0</version>
9090
</dependency>
9191
<dependency>
92-
<groupId>junit</groupId>
93-
<artifactId>junit</artifactId>
94-
<version>4.13.2</version>
92+
<groupId>org.junit.jupiter</groupId>
93+
<artifactId>junit-jupiter-engine</artifactId>
94+
<version>5.13.0-M2</version>
9595
<scope>test</scope>
9696
</dependency>
9797
</dependencies>
@@ -227,10 +227,6 @@
227227
<groupId>org.apache.maven.plugins</groupId>
228228
<artifactId>maven-compiler-plugin</artifactId>
229229
<version>${compiler-plugin-version}</version>
230-
<configuration>
231-
<source>${java-source-version}</source>
232-
<target>${java-target-version}</target>
233-
</configuration>
234230
</plugin>
235231
<plugin>
236232
<groupId>org.apache.maven.plugins</groupId>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.ibm.docling;
22

3+
import org.graalvm.polyglot.Context;
4+
35
public class HelloWorld {
46
public static void main(String[] args) {
5-
System.out.println("Hello, World!");
7+
try (Context context = Context.create()) {
8+
context.eval("python", "print('Hello from GraalPy!')");
9+
}
610
}
7-
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.ibm.docling;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
import org.graalvm.polyglot.Context;
8+
import org.graalvm.polyglot.Value;
9+
10+
public class GraalPyTest {
11+
12+
@Test
13+
public void testMain() {
14+
try (Context context = Context.newBuilder().allowAllAccess(true).build()) {
15+
Value result = context.eval("python", "'Hello from GraalPy!'");
16+
assertEquals("Hello from GraalPy!", result.asString());
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)