Generate projects that have:
- a scala app built in the root project
- a cpp native lib built in a sub-project dependency
- a superjar containing the native shared libs - ready to run
sbt new navicore/navijni.g8
cd into the newly created project dir and:
sbt javah run
sbt javah assembly
- copy the superjar from
target/scala-2.12/
to your installation - run via:
java -jar target/scala-2.12/<YOUR PROJECT NAME>.jar
- edit your generated Scala native wrapper found in
src/main/scala
, adding, changing, and deleting native methods - rerun
sbt javah
- edit the native module in
native/src
and implement the functions from thejavah
generated header file found intarget/native/include/
- edit
native/src/CMakeLists.txt
adding external native libs that need linking, ie add the following after add_library if you are linking libwiringPi:find_library(wiringPi_LIB wiringPi) target_link_libraries(${LIB_NAME} ${wiringPi_LIB})
sbt javah test
sbt javah run
sbt javah assembly
to create superjar
TODO:
test
,run
,assembly
should automaticallyjavah
- cross compiling (Raspberry PI, MacOS, Intel Linux, etc...)
- a compilation database automatically generated (via bear / Build EAR?)
- document publishing the lib to maven