java - Using a native Maven artifact (nar) in a webapp -


i have native shared library built , packaged using maven-nar plugin. works great , builds on linux/macosx/windows. i've defined jni library, built using maven-nar, wraps shared library. both of these produced nar artifacts , require maven-nar plugin in order used.

the problem arises when declaring dependency on these nars non-nar-packaged project. maven-nar plugin never seems invoked. when change project's packaging nar maven-nar plugin kick in. makes seem nar packaging needs infectious in order work, if there's nar dependency upstream projects need nar-packaged. correct or missing something?

can native shared library , jni artifacts produced using maven-nar plugin used in web applications, i.e. wars? if can used , deployed in war, how done? otherwise, option manually place native libraries in location in java.library.path on app server?

here's snippet of pom project depends on nar jni artifact:

  <?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/maven-v4_0_0.xsd">   <modelversion>4.0.0</modelversion>    <parent>     <groupid>thegroup</groupid>     <artifactid>theparent</artifactid>     <version>1.0-snapshot</version>     <relativepath>../pom.xml</relativepath>   </parent>    <artifactid>thedependant</artifactid>   <packaging>jar</packaging>   <name>a nice name</name>    ...    <properties>     <skiptests>true</skiptests>   </properties>    ...    <build>     <plugins>        <plugin>          <groupid>org.apache.maven.plugins</groupid>          <artifactid>maven-nar-plugin</artifactid>          <version>2.1-snapshot</version>        </plugin>     </plugins>   </build>    ...    <dependencies>     <dependency>       <groupid>thegoup</groupid>       <artifactid>thejni</artifactid>       <version>1.0-snapshot</version>       <type>nar</type>     </dependency>   </dependencies>    ...  </project> 

no, or @ least, not easily.

if have jni, need mess -djava.library.path , perhaps ld_library_path/dyld_library_path/path, , has happen in launch of overall container. there's no mechanism propagating inside war container.

in full-blown java ee, jca model / intended way native code gets integrated in web applications. typical lightweight containers don't support it.

if native code has no dependencies on other shared libs, , if aren't concerned jvm native code conflicts (a given native class can in 1 class loader), problem merely getting shared objects war file @ all.

http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

is 1 approach. use maven-dependency-plugin drop shared lib(s) directory under ${project.build.directory} , pick them 'web resources'.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -