I have a simple JNI-based project up to experiment with the nar-maven-plugin
. I'm running Windows 10 and am using MinGW compilers. I'm compiling the native code as C++ rather than C, although I don't think that matters for this question. (The native implementations in the "real" project will use C++, so just changing this is not trivial once I move beyond this initial test.)
In order to make this build with maven install
via the Eclipse IDE, I need to specify the linker explicitly in the POM file as part of the plug-in configuration
. The relevant section is here:
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.5.1</version>
<extensions>true</extensions>
<configuration>
<linker>
<name>g++</name>
<options>
<option>-Wl,--kill-at</option>
</options>
</linker>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>com.mycompany.sandbox</narSystemPackage>
</library>
</libraries>
</configuration>
</plugin>
If I do this, then I'm good on my local machine, but I believe that I've specialized my POM to certain machines / linkers. If I take it out completely, then I get this error:
[INFO] --- nar-maven-plugin:3.5.1:nar-validate (default-nar-validate) @ nar-test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.786 s
[INFO] Finished at: 2017-06-29T17:05:34-04:00
[INFO] Final Memory: 8M/23M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.maven-nar:nar-maven-plugin:3.5.1:nar-validate (default-nar-validate) on project nar-test: Execution default-nar-validate of goal com.github.maven-nar:nar-maven-plugin:3.5.1:nar-validate failed. NullPointerException -> [Help 1]
If I leave the <name>g++</name>
part and delete just the options, then it compiles but my test fails because it cannot link to the native implementation at run-time. (That's related to the --kill-at
flag and a known issue, so it's not a terrible surprise.)
Is there a known way to handle this issue such that I get a machine-independent POM that works?