You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Benson Margulies <bi...@gmail.com> on 2015/08/01 21:05:43 UTC
Re: Automating the build of a JNI based application
Look for the modern nar plugin on github.
On Fri, Jul 31, 2015 at 12:59 PM, Karl Heinz Marbaise <kh...@gmx.de> wrote:
> Hi,
>
> On 7/31/15 6:51 PM, Dušan Rychnovský wrote:
>>
>> 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.
>
>
> Nor should it cause Maven 1 is simply dead..
>
>
>>
>> * 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).
>
>
> which is not really astonishing...
>
>
>>
>> * 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
>>
>
> I woudl suggest to take a look into the nar-maven-plugin:
>
> http://maven-nar.github.io/
>
> which might be better fit your needs..
>
> Kind Regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> 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: Automating the build of a JNI based application
Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,
I would suggest to use Maven 3.X and not Maven 2.X anymore...but apart
from that the site shows Maven minimum 2.0.9[2]...which looks like a bug...
Furthermore please be aware of EoL for Maven 2 [1].
[1] http://maven.apache.org/maven-2.x-eol.html
[2] http://maven-nar.github.io/plugin-info.html
On 8/3/15 9:01 AM, Dušan Rychnovský wrote:
> Hi,
>
> Thanks for your suggestions.
>
> I tried the nar-maven-plugin as described on the usage page (
> http://maven-nar.github.io/usage.html). I have the following pom:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project
> xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>cz....</groupId>
> <artifactId>...</artifactId>
> <version>1.0-SNAPSHOT</version>
> <packaging>nar</packaging>
>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.1</version>
> <configuration>
> <source>1.7</source>
> <target>1.7</target>
> </configuration>
> </plugin>
> <plugin>
> <groupId>com.github.maven-nar</groupId>
> <artifactId>nar-maven-plugin</artifactId>
> <version>3.2.3</version>
> <extensions>true</extensions>
> <configuration>
> <libraries>
> <library>
> <type>jni</type>
> <narSystemPackage>cz....</narSystemPackage>
> </library>
> </libraries>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> And the following maven version:
>
> *Apache Maven 2.2.1 (rdebian-4)*
>
> And when I run
>
> *mvn clean package*
>
> I get the following error
>
>
> *Internal error in the plugin manager executing goal
> 'com.github.maven-nar:nar-maven-plugin:3.2.3:nar-validate': Unable to load
> the mojo 'com.github.maven-nar:nar-maven-plugin:3.2.3:nar-validate' in the
> plugin 'com.github.maven-nar:nar-maven-plugin'. A required class is
> missing: org/sonatype/aether/resolution /ArtifactResolutionException
> org.sonatype.aether.resolution.ArtifactResolutionException*
> What's wrong?
>
> Thanks,
> Dusan
>
>
>
> 2015-08-01 21:05 GMT+02:00 Benson Margulies <bi...@gmail.com>:
>
>> Look for the modern nar plugin on github.
>>
>> On Fri, Jul 31, 2015 at 12:59 PM, Karl Heinz Marbaise <kh...@gmx.de>
>> wrote:
>>> Hi,
>>>
>>> On 7/31/15 6:51 PM, Dušan Rychnovský wrote:
>>>>
>>>> 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.
>>>
>>>
>>> Nor should it cause Maven 1 is simply dead..
>>>
>>>
>>>>
>>>> * 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).
>>>
>>>
>>> which is not really astonishing...
>>>
>>>
>>>>
>>>> * 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
>>>>
>>>
>>> I woudl suggest to take a look into the nar-maven-plugin:
>>>
>>> http://maven-nar.github.io/
>>>
>>> which might be better fit your needs..
>>>
>>> Kind Regards
>>> Karl Heinz Marbaise
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>
Mit freundlichem Gruß
Karl-Heinz Marbaise
--
SoftwareEntwicklung Beratung Schulung Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl-Heinz Marbaise USt.IdNr: DE191347579
Hauptstrasse 177
52146 Würselen http://www.soebes.de
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Automating the build of a JNI based application
Posted by Dušan Rychnovský <ge...@gmail.com>.
Hi,
Thanks for your suggestions.
I tried the nar-maven-plugin as described on the usage page (
http://maven-nar.github.io/usage.html). I have the following pom:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cz....</groupId>
<artifactId>...</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>nar</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>cz....</narSystemPackage>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
</project>
And the following maven version:
*Apache Maven 2.2.1 (rdebian-4)*
And when I run
*mvn clean package*
I get the following error
*Internal error in the plugin manager executing goal
'com.github.maven-nar:nar-maven-plugin:3.2.3:nar-validate': Unable to load
the mojo 'com.github.maven-nar:nar-maven-plugin:3.2.3:nar-validate' in the
plugin 'com.github.maven-nar:nar-maven-plugin'. A required class is
missing: org/sonatype/aether/resolution /ArtifactResolutionException
org.sonatype.aether.resolution.ArtifactResolutionException*
What's wrong?
Thanks,
Dusan
2015-08-01 21:05 GMT+02:00 Benson Margulies <bi...@gmail.com>:
> Look for the modern nar plugin on github.
>
> On Fri, Jul 31, 2015 at 12:59 PM, Karl Heinz Marbaise <kh...@gmx.de>
> wrote:
> > Hi,
> >
> > On 7/31/15 6:51 PM, Dušan Rychnovský wrote:
> >>
> >> 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.
> >
> >
> > Nor should it cause Maven 1 is simply dead..
> >
> >
> >>
> >> * 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).
> >
> >
> > which is not really astonishing...
> >
> >
> >>
> >> * 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
> >>
> >
> > I woudl suggest to take a look into the nar-maven-plugin:
> >
> > http://maven-nar.github.io/
> >
> > which might be better fit your needs..
> >
> > Kind Regards
> > Karl Heinz Marbaise
> >
> > ---------------------------------------------------------------------
> > 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
>
>