<build> <!-- ... --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>process-classes</phase> <goals> <goal>run</goal> </goals> <configuration> <exportAntProperties>true</exportAntProperties> <target> <property name="runtime_classpath" refid="maven.compile.classpath"/> <exec executable="javah"> <arg value="-cp"/> <arg value="${runtime_classpath}"/> <arg value="-d"/> <arg value="${project.build.directory}/jni"/> <arg value="org.mbari.terrainnav.jni.TerrainNavNative"/> </exec> </target> </configuration> </execution> </executions> </plugin> <!-- ... --> </build>
To add your files with native methods just add space separated values to the line that contains org.mbari.terrainnav.jni.TerrainNavNative. For example, if you have classes foo.Bar and foo.Baz then that line would become:
<arg value="foo.Bar foo.Baz"/>
Why did I do it this way? Well, mainly the maven-antrun-plugin provides simple access to Maven's compile classpath. That classpath is required in order to execute javah correctly. I should note that ant has a javah task, but I was unable to get it to work with Maven. On the other hand, getting ant to execute javah directly was trivial.
0 comments:
Post a Comment