You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dave Rathnow <Da...@umsltd.com> on 2008/05/26 23:41:31 UTC

Can you build native lib and Jar with a single pom.xml?

 
I have built a pom to build a native JNI library but the Java class that
sits on top of it is in a separate project.  It makes running unit tests
a little tricky.  I would like to move the Java code into the same
project and have the Jar and the library built with a single pom.
 
Is this possible?  If so, how does one go about getting Maven to build
both a native library and a jar file?

Thanks,
Dave.

Re: Can you build native lib and Jar with a single pom.xml?

Posted by Stephen Connolly <st...@gmail.com>.
have you had a look at https://jna.dev.java.net

It makes calling native libraries a _lot_ easier

-Stephen

On Tue, May 27, 2008 at 4:52 AM, Brian Fox <br...@reply.infinity.nu> wrote:

> The golden rule is one pom, one artifact.
>
>
> On May 26, 2008, at 5:41 PM, "Dave Rathnow" <Da...@umsltd.com>
> wrote:
>
>
>> I have built a pom to build a native JNI library but the Java class that
>> sits on top of it is in a separate project.  It makes running unit tests
>> a little tricky.  I would like to move the Java code into the same
>> project and have the Jar and the library built with a single pom.
>>
>> Is this possible?  If so, how does one go about getting Maven to build
>> both a native library and a jar file?
>>
>> Thanks,
>> Dave.
>>
>>

Re: Can you build native lib and Jar with a single pom.xml?

Posted by Stephen Connolly <st...@gmail.com>.
One solution (the hack way) is to have antrun call the required build steps
for you, or even just fork the native code build tool

Another solution is to refactor your maven projects, take the unit tests out
of that module and put them into a third module.

A = java
B = jni
C = unit tests of java

B depends on A
C depends on B & A

On Tue, May 27, 2008 at 4:27 PM, Dave Rathnow <Da...@umsltd.com>
wrote:

>
> Okay.
>
> Can you explain how one uses Maven to build jni libraries?  Assume you
> have a jar project containing the Java source file (i.e. main and test)
> that provides the interface to the native code, and another project that
> contains the native code, how do you build them?
>
> Building the jar file requires the unit tests to run but they rely on
> the native library but it can't be built because it relys on the Java
> class in the jar file that is built from the Java project, but it can't
> be built because it can't run unit tests that rely on the native code
> from the native project but it can't be built....and on it goes. Chicken
> and Egg problem.
>
> How do you do this?
>
> Dave.
>
>
> -----Original Message-----
> From: Brian Fox [mailto:brianf@reply.infinity.nu]
> Sent: May 26, 2008 09:52 PM
> To: Maven Users List
> Subject: Re: Can you build native lib and Jar with a single pom.xml?
>
> The golden rule is one pom, one artifact.
>
> On May 26, 2008, at 5:41 PM, "Dave Rathnow" <Da...@umsltd.com>
> wrote:
>
> >
> > I have built a pom to build a native JNI library but the Java class
> > that
> > sits on top of it is in a separate project.  It makes running unit
> > tests
> > a little tricky.  I would like to move the Java code into the same
> > project and have the Jar and the library built with a single pom.
> >
> > Is this possible?  If so, how does one go about getting Maven to build
> > both a native library and a jar file?
> >
> > Thanks,
> > Dave.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Can you build native lib and Jar with a single pom.xml?

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Normally you would separate out the piece that is depended on in two
places to a separate module to break the circle.

-----Original Message-----
From: Dave Rathnow [mailto:Dave.Rathnow@umsltd.com] 
Sent: Tuesday, May 27, 2008 11:27 AM
To: Maven Users List
Subject: RE: Can you build native lib and Jar with a single pom.xml?


Okay.

Can you explain how one uses Maven to build jni libraries?  Assume you
have a jar project containing the Java source file (i.e. main and test)
that provides the interface to the native code, and another project that
contains the native code, how do you build them?  

Building the jar file requires the unit tests to run but they rely on
the native library but it can't be built because it relys on the Java
class in the jar file that is built from the Java project, but it can't
be built because it can't run unit tests that rely on the native code
from the native project but it can't be built....and on it goes. Chicken
and Egg problem.

How do you do this?

Dave.
 

-----Original Message-----
From: Brian Fox [mailto:brianf@reply.infinity.nu] 
Sent: May 26, 2008 09:52 PM
To: Maven Users List
Subject: Re: Can you build native lib and Jar with a single pom.xml?

The golden rule is one pom, one artifact.

On May 26, 2008, at 5:41 PM, "Dave Rathnow" <Da...@umsltd.com>
wrote:

>
> I have built a pom to build a native JNI library but the Java class  
> that
> sits on top of it is in a separate project.  It makes running unit  
> tests
> a little tricky.  I would like to move the Java code into the same
> project and have the Jar and the library built with a single pom.
>
> Is this possible?  If so, how does one go about getting Maven to build
> both a native library and a jar file?
>
> Thanks,
> Dave.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Can you build native lib and Jar with a single pom.xml?

Posted by Dave Rathnow <Da...@umsltd.com>.
Okay.

Can you explain how one uses Maven to build jni libraries?  Assume you
have a jar project containing the Java source file (i.e. main and test)
that provides the interface to the native code, and another project that
contains the native code, how do you build them?  

Building the jar file requires the unit tests to run but they rely on
the native library but it can't be built because it relys on the Java
class in the jar file that is built from the Java project, but it can't
be built because it can't run unit tests that rely on the native code
from the native project but it can't be built....and on it goes. Chicken
and Egg problem.

How do you do this?

Dave.
 

-----Original Message-----
From: Brian Fox [mailto:brianf@reply.infinity.nu] 
Sent: May 26, 2008 09:52 PM
To: Maven Users List
Subject: Re: Can you build native lib and Jar with a single pom.xml?

The golden rule is one pom, one artifact.

On May 26, 2008, at 5:41 PM, "Dave Rathnow" <Da...@umsltd.com>
wrote:

>
> I have built a pom to build a native JNI library but the Java class  
> that
> sits on top of it is in a separate project.  It makes running unit  
> tests
> a little tricky.  I would like to move the Java code into the same
> project and have the Jar and the library built with a single pom.
>
> Is this possible?  If so, how does one go about getting Maven to build
> both a native library and a jar file?
>
> Thanks,
> Dave.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Can you build native lib and Jar with a single pom.xml?

Posted by Brian Fox <br...@reply.infinity.nu>.
The golden rule is one pom, one artifact.

On May 26, 2008, at 5:41 PM, "Dave Rathnow" <Da...@umsltd.com>  
wrote:

>
> I have built a pom to build a native JNI library but the Java class  
> that
> sits on top of it is in a separate project.  It makes running unit  
> tests
> a little tricky.  I would like to move the Java code into the same
> project and have the Jar and the library built with a single pom.
>
> Is this possible?  If so, how does one go about getting Maven to build
> both a native library and a jar file?
>
> Thanks,
> Dave.
>

Re: Can you build native lib and Jar with a single pom.xml?

Posted by Haim Ashkenazi <ha...@gmail.com>.
Hi

IIRC Freehep nar plugin (http://java.freehep.org/freehep-nar-plugin/)
generates a jar and a nar (native archive) in the same pom.

Bye

On Tue, May 27, 2008 at 12:41 AM, Dave Rathnow <Da...@umsltd.com> wrote:
>
> I have built a pom to build a native JNI library but the Java class that
> sits on top of it is in a separate project.  It makes running unit tests
> a little tricky.  I would like to move the Java code into the same
> project and have the Jar and the library built with a single pom.
>
> Is this possible?  If so, how does one go about getting Maven to build
> both a native library and a jar file?
>
> Thanks,
> Dave.
>



-- 
Haim

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org