You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Luís Soares <lo...@di.uminho.pt> on 2006/09/11 18:14:10 UTC

Building Native Classes and library.

Hello all,
  I am trying to build native classes with maven2 but there is an issue when 
calling javah. 

  The things should happen in the following order:

    i) Build the java source classes that have calls to JNI.
   ii) Dump the class files into target/classes
  iii) Using the "native-maven-plugin" call "javah" to generate the header 
files. This needs the just compiled classes in target/classes in the 
classpath
   iv) Compile the C source files and create the library.

The problem is that the compiled classes are not available in the classpath 
when javah is called. Is there a way to do this without making use of an ant 
task?

How can I change the classpath when runnig the native-maven-plugin in order 
for the javah be called with -classpath $CLASSPATH:
${project.build.directory}/classes ?

If this is trivial, my apologies, but I have just started using maven.

Thanks.

-- 
Luís Soares

Re: Building Native Classes and library.

Posted by dan tran <da...@gmail.com>.
I went ahead with a fix, and deployed a snapshot

On 9/11/06, dan tran <da...@gmail.com> wrote:
>
>
> Please file a JIRA so that ${project.build.directory}/classes  will be add
> to javah classpath.
>
> However you can create your own jar project and make it a dependency of
> the javah project.
>
> Here is an example.
>
> http://svn.codehaus.org/mojo/trunk/mojo/maven-native/native-maven-plugin/src/it/jni/
>
>
> -D
>
>
>  On 9/11/06, Luís Soares <lo...@di.uminho.pt> wrote:
> >
> >
> > Hello all,
> > I am trying to build native classes with maven2 but there is an issue
> > when
> > calling javah.
> >
> > The things should happen in the following order:
> >
> >    i) Build the java source classes that have calls to JNI.
> >   ii) Dump the class files into target/classes
> > iii) Using the "native-maven-plugin" call "javah" to generate the header
> >
> > files. This needs the just compiled classes in target/classes in the
> > classpath
> >   iv) Compile the C source files and create the library.
> >
> > The problem is that the compiled classes are not available in the
> > classpath
> > when javah is called. Is there a way to do this without making use of an
> > ant
> > task?
> >
> > How can I change the classpath when runnig the native-maven-plugin in
> > order
> > for the javah be called with -classpath $CLASSPATH:
> > ${project.build.directory}/classes ?
> >
> > If this is trivial, my apologies, but I have just started using maven.
> >
> > Thanks.
> >
> > --
> > Luís Soares
> >
> >
> >
>

Re: Building Native Classes and library.

Posted by dan tran <da...@gmail.com>.
Please file a JIRA so that ${project.build.directory}/classes  will be add
to javah classpath.

However you can create your own jar project and make it a dependency of the
javah project.

Here is an example.
http://svn.codehaus.org/mojo/trunk/mojo/maven-native/native-maven-plugin/src/it/jni/


-D


On 9/11/06, Luís Soares <lo...@di.uminho.pt> wrote:
>
>
> Hello all,
> I am trying to build native classes with maven2 but there is an issue when
> calling javah.
>
> The things should happen in the following order:
>
>    i) Build the java source classes that have calls to JNI.
>   ii) Dump the class files into target/classes
> iii) Using the "native-maven-plugin" call "javah" to generate the header
> files. This needs the just compiled classes in target/classes in the
> classpath
>   iv) Compile the C source files and create the library.
>
> The problem is that the compiled classes are not available in the
> classpath
> when javah is called. Is there a way to do this without making use of an
> ant
> task?
>
> How can I change the classpath when runnig the native-maven-plugin in
> order
> for the javah be called with -classpath $CLASSPATH:
> ${project.build.directory}/classes ?
>
> If this is trivial, my apologies, but I have just started using maven.
>
> Thanks.
>
> --
> Luís Soares
>
>
>

Re: Building Native Classes and library.

Posted by Christophe DENEUX <ch...@capgemini.com>.
Hi Luis,

I think that your project organization is incorrect because you have a 
circular dependence: your source code needs the JNI lib (example: for 
runtime or testing purpose), and your library needs the java source code 
to generate header files.

If you use a multi-modules project with the following dependencies, that 
works fine (I use this decomposition):
    ----- java-api
      |
      |---java-native
      |
      |---lib-native



with:
     - java-api: the module containing all java classes that calls the 
JNI layer (the Java class containing the native methods is not included 
in this module)
     - java-native: the module containing all java classes that contain 
only native methods
     - lib-native: the DLL or .SO source code

dependencies:
    - java-api depends of java-native and lib-native, so it will build 
in last position
    - lib-native depends of java-native, so it will build in second position
    - java-native has no dependence, so it will be build in first
    

____________________________________________________________________________

Christophe DENEUX / Capgemini Sud / M�diterran�e
Technical Leader
Tel: + 33 4 93 72 43 74 / www.capgemini.com
Fax: + 33 4 93 21 02 95
Porte de l'Ar�nas - Entr�e B / 455 Promenade des Anglais / 06200 Nice

Join the Collaborative Business Experience
____________________________________________________________________________



Lu�s Soares a �crit :
> Hello all,
>   I am trying to build native classes with maven2 but there is an issue when 
> calling javah. 
>
>   The things should happen in the following order:
>
>     i) Build the java source classes that have calls to JNI.
>    ii) Dump the class files into target/classes
>   iii) Using the "native-maven-plugin" call "javah" to generate the header 
> files. This needs the just compiled classes in target/classes in the 
> classpath
>    iv) Compile the C source files and create the library.
>
> The problem is that the compiled classes are not available in the classpath 
> when javah is called. Is there a way to do this without making use of an ant 
> task?
>
> How can I change the classpath when runnig the native-maven-plugin in order 
> for the javah be called with -classpath $CLASSPATH:
> ${project.build.directory}/classes ?
>
> If this is trivial, my apologies, but I have just started using maven.
>
> Thanks.
>
>   


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.