Skip to content

Commit e6b4fe0

Browse files
authored
feat(client): publish GraalVM metadata files (#534)
* Generate the GraalVM metadata file(s) when releasing the project Fix #522 * Rename the GraalVM Agent profile to "graalvmAgent"
1 parent 067258e commit e6b4fe0

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/create-releases.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,37 @@ jobs:
3636
if: ${{ steps.release.outputs.releases_created }}
3737
uses: gradle/gradle-build-action@v2
3838

39+
- name: Compile the openai-java-core project
40+
run: |
41+
./gradlew :openai-java-core:compileJava :openai-java-core:compileTestJava -x test
42+
43+
- name: Run the Prism server
44+
run: |
45+
./scripts/mock --daemon
46+
47+
- name: Setup GraalVM
48+
uses: graalvm/setup-graalvm@v1
49+
with:
50+
java-version: 21
51+
distribution: 'graalvm-community'
52+
cache: gradle
53+
54+
- name: Run tests on the openai-java-core project with the GraalVM native-image agent
55+
run: |
56+
./gradlew :openai-java-core:test -x compileJava -x compileTestJava -x compileKotlin -x compileTestKotlin -PgraalvmAgent
57+
58+
- name: Check generated GraalVM file
59+
run: |
60+
echo "Checking for GraalVM agent metadata files..."
61+
DIRECTORY=openai-java-core/src/main/resources/META-INF/native-image
62+
if [ -d "$DIRECTORY" ] && [ "$(ls -A $DIRECTORY)" ]; then
63+
echo "Files found in $DIRECTORY:"
64+
ls -l $DIRECTORY
65+
else
66+
echo "No files found in $DIRECTORY"
67+
exit 1
68+
fi
69+
3970
- name: Publish to Sonatype
4071
if: ${{ steps.release.outputs.releases_created }}
4172
run: |-

openai-java-core/build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id("java")
23
id("openai.kotlin")
34
id("openai.publish")
45
}
@@ -43,3 +44,19 @@ dependencies {
4344
testImplementation("org.mockito:mockito-junit-jupiter:5.14.2")
4445
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
4546
}
47+
48+
if (project.hasProperty("graalvmAgent")) {
49+
java {
50+
toolchain {
51+
languageVersion.set(JavaLanguageVersion.of(21))
52+
vendor.set(JvmVendorSpec.GRAAL_VM)
53+
}
54+
}
55+
56+
tasks.test {
57+
maxParallelForks = 1
58+
forkEvery = 0
59+
jvmArgs =
60+
listOf("-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image")
61+
}
62+
}

0 commit comments

Comments
 (0)