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.cpp-language'
}
build.gradle.kts
plugins {
	id("java")
	id("dev.nokee.jni-library")
	id("dev.nokee.cpp-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-cpp-jni-library.jar

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

$ jar tf ./build/libs/java-cpp-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-cpp-jni-library.dylib

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