I mavenize my java-project and don't understand, how add in it native libraries. In my not-maven project i did it via CLASSPATH. I use NetBeans and maven in it.
+1
A:
If you just want to add the native libraries to the class path, try to put them in src/main/resources
.
Update: You can specify where resources exist in the POM:
<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">
<build>
...
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/native</directory>
<includes>
<include>native.so</include>
</includes>
</resource>
</resources>
<testResources>
...
</testResources>
...
</build>
</project>
But honestly, if you decide to use Maven, you should adopt Maven's standard layout (or you'll have to configure every plugin for your custom layout which is more a source of problems than benefits).
Pascal Thivent
2010-03-15 16:34:15
sorry, i'm newbie in maven, but my project have different structure. what i should to do?
EK
2010-03-15 16:39:20
@EK Either put the native libraries in the directory you defined as `<resource>` or add details to your question (like your POM and project structure) so that I can provide more guidance.
Pascal Thivent
2010-03-15 16:48:41
my project structure very simple.only one folder /src/ (and test, bin, config,target, lib).what i should change in pom, to said maven use resource folder with libs.this is most interesting part of my pom, i think<build> <sourceDirectory>src</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <plugins>THANKS!
EK
2010-03-15 17:03:23
in my classpath i have environment variable with path to libraries
EK
2010-03-15 17:14:43
@EK This is not how things work in Maven and, actually, a JNI project is really not the easiest way to start with Maven. Maybe you should stick with Ant here (especially if you don't want to follow maven's principles and conventions).
Pascal Thivent
2010-03-15 17:24:23
i did next<build> <sourceDirectory>src</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <resources> <resource> <directory> resources </directory> <includes> <include>*.so</include> </includes> </resource> </resources> <plugins>but when i run project, it is not see libs. all libs in folder resources
EK
2010-03-15 17:27:26
maybe it is somthing like LD_LIBRARY_PATH ?
EK
2010-03-15 17:34:56
thx, i think about it
EK
2010-03-15 17:42:41
@EK You'll find some answers in http://stackoverflow.com/questions/2410384/managing-native-libraries-with-maven and the various links mentioned in there (http://stackoverflow.com/questions/1962718/maven-and-the-jogl-library/1969077#1969077, http://www.humboldt.co.uk/2009/02/wrapping-a-native-library-with-maven.html). As I said, JNI isn't an easy topic and analyzing snippets posted in a 600 chars box isn't really possible. Moreover, your problem is kinda hard to reproduce so I'm sorry but I can't help more.
Pascal Thivent
2010-03-15 18:02:37