You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship.

This sample shows how a JNI library implemented in Java and C can be built with Gradle. The library has no dependencies, and the build has a minimal configuration.

build.gradle
plugins {
	id 'java'
	id 'dev.nokee.jni-library'
	id 'dev.nokee.c-language'
}
build.gradle.kts
plugins {
	id("java")
	id("dev.nokee.jni-library")
	id("dev.nokee.c-language")
}

To build the library:

$ ./gradlew assemble

BUILD SUCCESSFUL
4 actionable tasks: 4 executed

The JNI library produced inside ./build/libs directory:

$ ls ./build/libs/*.jar
./build/libs/java-c-jni-library.jar

Since there is only one variant, the native component is included inside the main JAR:

$ jar tf ./build/libs/java-c-jni-library.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/example/
com/example/greeter/
com/example/greeter/NativeLoader.class
com/example/greeter/Greeter.class
libjava-c-jni-library.dylib

For more information, see JNI Library Plugin and C Language Plugin reference chapters.