Build a MSVC DLL with JNI headers generated by javahThe example uses javah to generate native header files which are then be part of the native build to create a Windows DLL Note:
<project>
...
<packaging>dll</packaging>
<dependencies>
<dependency>
your jar which has jni interface.
</dependency>
<dependency>
other native library ( .lib, .so, .a, .o, etc)
to be linked in.
</dependency>
...
</dependencies>
...
<build>
<!-- The global source and test directory are used -->
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jfrog.jade.plugins</groupId>
<artifactId>jade-native-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<compilerProvider>msvc</compilerProvider>
<!-- setup compiler and linker environment according to msvc 6 vcvars32.bat -->
<!-- without this setting, you will need to setup the environment outside -->
<!-- of Maven -->
<envFactoryName>org.codehaus.mojo.natives.msvc.MSVC6EnvFactory</envFactoryName>
<compilerStartOptions>
<compilerStartOption> /MD /W4 -O</compilerStartOption>
<compilerStartOption>-D_WIN32_WINNT=0x0500 </compilerStartOption>
</compilerStartOptions>
<!--
| Add jdk include directories to system include path
| Override ${jkdIncludePath} If your jdk does not conform to Sun JDK layout
-->
<javahOS>win32</javahOS>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<!-- deploy the accompany .lib file as well -->
<linkerSecondaryOutputExtensions>lib</linkerSecondaryOutputExtensions >
<linkerStartOptions>
<linkerStartOption> /INCREMENTAL:NO /DLL user32.lib advapi32.lib oldnames.lib kernel32.lib </linkerStartOption>
</linkerStartOptions>
</configuration>
<!-- Generate JNI header files based on a list of class name on the classpath -->
<!-- The generated include directory is automatically added to include path at compile phase -->
<!-- Ensure to have appropriate denpendency jar file(s) in your pom -->
<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<classNames>
<className>class1</className>
<className>class2</className>
<className>...</className>
</classNames>
<!--
| Note:
| 1. Without classNames, javah mojo will search for all JNI classes
| in your dependency list.
-->
</configuration>
<goals>
<goal>javah</goal>
</goals>
</execution>
</executions>
</build>
</project> |
|||