Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stwind/gradle-jni
Sample project setup for working with Java Native Interface with Gradle
https://github.com/stwind/gradle-jni
gradle java jni
Last synced: about 2 months ago
JSON representation
Sample project setup for working with Java Native Interface with Gradle
- Host: GitHub
- URL: https://github.com/stwind/gradle-jni
- Owner: stwind
- Created: 2020-05-13T10:33:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-15T13:19:21.000Z (over 4 years ago)
- Last Synced: 2024-04-17T02:00:15.826Z (10 months ago)
- Topics: gradle, java, jni
- Language: Java
- Size: 72.3 KB
- Stars: 19
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JNI Project With Gradle
A sample project setup/workflow for building JNI libraries (C++) with Gradle for references.
Features
* [Automatic JNI header generation](jni-lib/build.gradle#L24)
* [Load shared libraries embeded in Jar](jni-lib/src/main/java/jni/Tools.java#L5)
* [Unittest JNI with JUnit 5](jni-lib/build.gradle#L48)Tested on
* Mac OS X
* Ubuntu (focal)## Prerequisite
* OpenJDK 11+
* CMake 3.13+## Building
Clone the repo
```sh
$ git clone https://github.com/stwind/gradle-jni.git
$ cd gradle-jni
$ ./gradlew run
```The output should be something like
```
Downloading https://services.gradle.org/distributions/gradle-6.4-bin.zip
.........10%..........20%..........30%..........40%.........50%..........60%..........70%..........80%.........90%..........100%Welcome to Gradle 6.4!
Here are the highlights of this release:
- Support for building, testing and running Java Modules
- Precompiled script plugins for Groovy DSL
- Single dependency lock file per projectFor more details see https://docs.gradle.org/6.4/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :jni-lib:compileJNI
-- The CXX compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Java: /usr/lib/jvm/java-13-openjdk-amd64/bin/java (found version "13.0.3")
-- Found JNI: NotNeeded
-- Configuring done
-- Generating done
-- Build files have been written to: /root/gradle-jni/jni-lib/build/natives
Scanning dependencies of target tools
[ 50%] Building CXX object src/main/cpp/CMakeFiles/tools.dir/tools.cpp.o
[100%] Linking CXX shared library ../../../lib/libtools.so
[100%] Built target tools> Task :jni-runner:run
foobarBUILD SUCCESSFUL in 26s
6 actionable tasks: 6 executed
```