Skip to content

feat(client): publish GraalVM metadata files#534

Merged
TomerAberbach merged 2 commits intoopenai:nextfrom
jdubois:fix-522-2
Jul 17, 2025
Merged

feat(client): publish GraalVM metadata files#534
TomerAberbach merged 2 commits intoopenai:nextfrom
jdubois:fix-522-2

Conversation

@jdubois
Copy link
Copy Markdown
Contributor

@jdubois jdubois commented Jul 15, 2025

This adds support for generating the GraalVM metadata when releasing the project, as mentioned in #522

The setup is a bit complex because:

  • The current build of Kotlin doesn't work with a recent Java version (Java 24)
  • But the GraalVM native image needs a recent version for licensing issues (you need a commercial license for version 17)

So the way this is done here is:

  • Compile the module with Java 17, so it works fine with Kotlin
  • Run the tests over the compiled code with GraalVM 21 (it won't work with 24, and 21 doesn't require a commercial license)

At some point this will all need to migrate to Java 24: at that moment, please note that GraalVM will have a new file format, and will generate only one file instead of several (but always in the same directory, so this code should still work OK).

I'm keeping the full "publish to Sonatype" task, to have everything fully compiled and tested for the release. That means the tests will run twice - this could be fixed by adding -x test to that task.

Another way to achieve this would be to use the GraalVM Gradle task instead of adding the agent library like we do here as a JVM argument: this seems more elegant, but that approach cannot work currently as it would require to import that task (the task only run when the "agent" profile is set up, but the import would always be there as they can't be conditionally imported). And as that task cannot run with Java 17, that would make the Kotlin build fail. This is something that could be improved later, when the project will work with Java 24.

@jdubois jdubois requested a review from a team as a code owner July 15, 2025 09:40
@TomerAberbach
Copy link
Copy Markdown
Collaborator

Curious what errors you ran into with Java 24 if you still have them?

@jdubois
Copy link
Copy Markdown
Contributor Author

jdubois commented Jul 16, 2025

With Java 24, I had this error, using the configuration at https://github.com/jdubois/openai-java/blob/6a8d908bb52af8a4b2bea74786318dc161521f71/.github/workflows/test.yml , when running the tests:

> Could not create task ':openai-java-core:test'.
   > Could not create task of type 'Test'.
      > Could not create an instance of type org.gradle.api.internal.tasks.testing.DefaultTestTaskReports.
         > Could not create an instance of type org.gradle.api.reporting.internal.DefaultReportContainer.
            > Type T not present

@TomerAberbach TomerAberbach changed the base branch from main to next July 17, 2025 21:14
@TomerAberbach TomerAberbach changed the title Generate the GraalVM metadata file(s) when releasing the project feat(client); publish GraalVM metadata files Jul 17, 2025
@TomerAberbach TomerAberbach changed the title feat(client); publish GraalVM metadata files feat(client): publish GraalVM metadata files Jul 17, 2025
@TomerAberbach TomerAberbach merged commit e6b4fe0 into openai:next Jul 17, 2025
2 of 3 checks passed
@stainless-app stainless-app bot mentioned this pull request Jul 17, 2025
TomerAberbach pushed a commit that referenced this pull request Jul 17, 2025
* 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"

* release: 2.16.0

---------

Co-authored-by: Julien Dubois <[email protected]>
Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
@fniephaus
Copy link
Copy Markdown

Glad to see GraalVM support! Have you considered adding this library to this list on the GraalVM website?

If you would like to add your library and framework to this list, open a pull request and add an entry to this file according to this schema.

@jdubois
Copy link
Copy Markdown
Contributor Author

jdubois commented Nov 4, 2025

@fniephaus I'd love to, however the file points to the metadata locations on GitHub, and those are not available: they are generated at release time, using the GraalVM agent, so there's nothing to point to in the repository.

@fniephaus
Copy link
Copy Markdown

fniephaus commented Nov 4, 2025

I'd love to, however the file points to the metadata locations on GitHub, and those are not available: they are generated at release time

Not a problem, I think we'd accept something like this link:

- name: Check generated GraalVM file
run: |
echo "Checking for GraalVM agent metadata files..."
DIRECTORY=openai-java-core/src/main/resources/META-INF/native-image
if [ -d "$DIRECTORY" ] && [ "$(ls -A $DIRECTORY)" ]; then
echo "Files found in $DIRECTORY:"
ls -l $DIRECTORY
else
echo "No files found in $DIRECTORY"
exit 1
fi

@jdubois
Copy link
Copy Markdown
Contributor Author

jdubois commented Nov 4, 2025

Thanks! Done at oracle/graalvm-reachability-metadata#706

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants