GitPedia

Gradle jextract

Gradle plugin for integrating Project Panama's jextract tool

From krakowski·Updated April 18, 2026·View on GitHub·

This is a Gradle plugin for integrating Project Panama's [`jextract`](https://github.com/openjdk/jextract) tool in the build process. There is also a [full demo project](https://github.com/krakowski/jextract-demo) showcasing the `gradle-jextract` plugin. The project is written primarily in Kotlin, distributed under the GNU General Public License v3.0 license, first published in 2020. Key topics include: ffi, gradle, gradle-plugin, java, jextract.

Latest release: 0.5.0v0.5.0
April 3, 2024View Changelog →

GitHub Workflow Status
Gradle Plugin Portal

This is a Gradle plugin for integrating Project Panama's jextract tool in the build process.
There is also a full demo project showcasing the gradle-jextract plugin.

:bulb:   Example

Since the plugin is available on Gradle's Plugin Portal it can be applied within the build script's plugins block.

gradle
plugins { id "io.github.krakowski.jextract" version "0.5.0" }

Applying the plugin adds the jextract task which can be configured by the build script.

gradle
jextract { header("${project.projectDir}/src/main/c/stdio.h") { // The library name libraries = [ 'stdc++' ] // The package under which all source files will be generated targetPackage = 'org.unix' // The generated class name className = 'Linux' } }

If the Gradle Java Plugin or
Application plugin is applied, the gradle-jextract
plugin configures them and uses the configured toolchain for its task, which can be set as follows.

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(22))
    }
}

If your JDK is not installed in one of the default locations, Gradle can be instructed to search in a custom location.
To enable this feature the org.gradle.java.installations.paths property has to be set within your global gradle.properties
file usually located inside ${HOME}/.gradle.

org.gradle.java.installations.paths=/custom/path/jdk22

The plugin will first try to find jextract inside PATH and then fall back to ${JAVA_HOME}/bin.

:triangular_ruler:   Configuration Options

The jextract task exposes the following configuration options.

NameTypeRequiredDescription
librariesjava.lang.String[]The libraries against which the native code will link ¹
includesjava.lang.String[]A list of directories which should be included during code generation
targetPackagejava.lang.String:black_circle:The package under which all bindings will be generated
classNamejava.lang.StringThe generated class file's name
functionsjava.lang.String[]Whitelist of function symbols
constantsjava.lang.String[]Whitelist of macro and enum constant symbols
structsjava.lang.String[]Whitelist of struct symbols
typedefsjava.lang.String[]Whitelist of typedef symbols
unionsjava.lang.String[]Whitelist of union symbols
variablesjava.lang.String[]Whitelist of global variable symbols
definedMacrosjava.lang.String[]List of additional defined C preprocessor macros
useSystemLoadLibraryjava.lang.BooleanLoad libraries into the loader symbol lookup
outputDirorg.gradle.api.file.DirectoryThe output directory under which the generated source files will be placed

:green_book:   Notes

¹ libraries option can use simple library name "stdc++" or full path to the shared libraries.
Full path need to be prefixed with ":" character.
For example ":/usr/lib/libstdc++.so"
doc

:wrench:   Requirements

:scroll:   License

This project is licensed under the GNU GPLv3 License - see the LICENSE file for details.

Contributors

Showing top 8 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from krakowski/gradle-jextract via the GitHub API.Last fetched: 6/28/2026