Hi,

I'm creating a JNI wrapper on top of a C++ library. I'd like to have a
"one-click" Maven build for the whole application. When building it
manually, I need to do the following:

javac ... (compile the Java source files)
javah ... (generate JNI header files from Java class files)
g++   ... (compile the JNI source files + link them with the static library)

I'm looking for a way to have these commands executed by Maven.

I looked at the native-maven-plugin (
http://maven.apache.org/archives/maven-1.x/plugins/native/index.html) and
I'm afraid it will not work for me.

* The documentation is extremely insufficient (there is literally no
official documentation on the plugin site and nor is there any information
elsewhere on the Internet).

* I cannot even look at the source-code as it isn't there in the SVN
repository linked from the plugin site.

* I tried to make it work based on the two SO posts I discovered but I
couldn't.

I'm thinking about the following project layout:

/src
/src/main
/src/main/java    ... the Java interfaces with native methods
/src/main/native ... the C++ implementation of the generated header files

The static library itself is a product of a different project and will be
installed on my system in a standard location (i.e. outside of this
project).

What I need is essentially to call the javah and g++ commands after the
Java .class files have been generated. The g++ command is non-trivial,
there are quite a few compiler and linker options that need to be applied.
The generated library file should not be a part of the generated JAR file,
it should be a separate artifact.

I was thinking maybe I'll need to use the exec-maven-plugin (
http://www.mojohaus.org/exec-maven-plugin/index.html) and run the commands
manually? Or is there a better way to do this?

Also, once the library is generated, I'd like to have Maven run some test
cases using the generated JNI wrapper to make sure it works correctly.

Thanks very much for your help.

Kind regards,
Dusan

Reply via email to