Examples
The nar-maven-plugin repository contains a collection of integration tests in the src/it directory. These examples demonstrates different usage scenarios and can be useful to learn how to use NAR.
Running the tests standalone require a little hacking, since they are not intended as unit-tests. Still, you can build and run them by replacing <groupId>@project.groupId@</groupId> with <groupId>com.github.maven-nar</groupId> in the pom.xml files. Then, navigate to each test folder and invoke mvn test.
The following examples are available:
- it0001-executable
- A C routine.
- it0002-executable-static
- A C routine statically linked with the C-runtime library.
- it0003-jni
- A C routine called from Java.
- it0004-java-dep-jni
- A NAR JNI project which depends on "jni".
- it0005-jni-static
- A C routine called from Java statically linked with the C-runtime library.
- it0006-jni-3rdparty
- A third party JNI library called from Java. The third party library is the "jni" from the example above and is added as resource to the project in the form of a JNI library and a corresponding jar file. The "jni" lib is currently provided for the following platforms:
- it0007-lib-shared
- A C routine which gets archived into a shared library. A C test executable is created.
- it0008-executable-dep-lib-shared
- A C executable which depends on "lib-shared" and links dynamically with it. The executable is created and run.
- it0009-jni-dep-lib-shared
- A C routine called from Java, which depends on "lib-shared" and links dynamically with it.
- it0010-lib-static
- A C routine which gets archived into a static library. A C test executable is created.
- it0011-executable-dep-lib-static
- A C executable which depends on "lib-static" and links statically with it. The executabe is created and run.
- it0012-jni-dep-lib-static
- A C routine called from Java, which depends on "lib-static" and links statically with it.
- it0013-gnu-executable
- A gnu autogen and configurable package.
- it0014-multi-module
- A multi module package, consisting of a library and an executable dependent on that library.
- it0015-cpp-executable
- A C++ program.
- it0016-layout
- Tests for different repository layouts, currently NarLayout20 and NarLayout21.
- it0017-toolchain
- Tests which use the toolchain to find tools such as javah.
- it0018-fortran
- A Fortran 90 program, not enabled on Windows.
- it0019-compiler
- Test to run with the Intel compiler.
- it0020-lib-3rdparty
- A 3rd party library, including header files.
- it0021-executable-dep-lib-3rdparty
- An executable dependent on the 3rd party library.
- it0025-jar-dep-jni
- A JAR project which depends on "jni".
- it0026-native-lib-loader
- A demonstration of how to unpack native libraries at runtime from ".nar" files present on the class path, using the `native-lib-loader` library.
These examples are now all run as integration tests by running maven on the nar-maven-plugin from its top-level directory with the profile "run-its".