Discussion:
How to link native library to a Maven Dependency in Eclipse?
obido
2009-11-18 03:02:14 UTC
Permalink
I don't know if this is trivial but I just can't find a good solution to this
problem since I switched to Maven.

Before Maven I added jars to libraries under Java Build Path. Then went in
under Referenced Libraries and right clicked the jar and set the native
library. If I try to do the same with a jar under Maven Dependencies it
doesn't work. Setting source and javadoc works but the Native Library path
is just cleared and don't get saved. Is this a bug?

I'm running eclipse 3.4.2 and m2eclipse 0.9.8.

So right now if I have a project with alot of runnable examples I have to
set -Djava.library.path for every run setting :X.

-Thomas
--
View this message in context: http://old.nabble.com/How-to-link-native-library-to-a-Maven-Dependency-in-Eclipse--tp26401720p26401720.html
Sent from the Maven Eclipse - User mailing list archive at Nabble.com.
Igor Fedorenko
2009-11-18 14:53:27 UTC
Permalink
m2e does not currently support native libraries. Please file enhancement
request in m2e JIRA [1], although this most likely won't be in 1.0
unless somebody contributes a patch.

Out of curiosity, how do you build this on cli?

--
Regards,
Igor

[1] https://issues.sonatype.org/browse/MNGECLIPSE
Post by obido
I don't know if this is trivial but I just can't find a good solution to this
problem since I switched to Maven.
Before Maven I added jars to libraries under Java Build Path. Then went in
under Referenced Libraries and right clicked the jar and set the native
library. If I try to do the same with a jar under Maven Dependencies it
doesn't work. Setting source and javadoc works but the Native Library path
is just cleared and don't get saved. Is this a bug?
I'm running eclipse 3.4.2 and m2eclipse 0.9.8.
So right now if I have a project with alot of runnable examples I have to
set -Djava.library.path for every run setting :X.
-Thomas
obido
2009-11-19 06:27:11 UTC
Permalink
Post by Igor Fedorenko
m2e does not currently support native libraries. Please file enhancement
request in m2e JIRA [1], although this most likely won't be in 1.0
unless somebody contributes a patch.
Out of curiosity, how do you build this on cli?
--
Regards,
Igor
[1] https://issues.sonatype.org/browse/MNGECLIPSE
Well the natives are part of a third party lib. In this case LWJGL. I guess
your question is how I get the natives into my project from the repository?

Since LWJGL isn't available from a maven repository I had to make on
myself.. looks something like this
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1-javadoc.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1-natives_linux.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1-natives_macosx.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1-natives_solaris.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1-natives_windows.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1-sources.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1.jar
repository\org\lwjgl\lwjgl\2.2.1\lwjgl-2.2.1.pom

My pom has 4 profiles. linux,macosx,solaris and windows

in the maven-dependency-plugin I do this
<execution>
<id>unpack-dependencies-natives</id>
<phase>compile</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<classifier>natives_${build.type}</classifier>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>

<outputDirectory>${project.build.directory}/lib/natives</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>

so I actually get all 3dparty native dependencies under target/lib/natives.

Since I can't link natives to jars managed by m2eclipse I have disabled
Dependency Management. The way I do it now is that I do unpack-dependencies
for all 3dparty libs so I get
target/lib/natives
target/lib/classes
target/lib/sources

Then I add the classes dir as a class folder library. Then assign the
natives and source directory. Works like a charm(only draw back is that I
can't unpack javadocs since they would overwrite for each other). Tho I
wouldn't mind using the Dependency Managment system if there was a way to
link the natives.

I just wish there was a standardized classifier name for natives that all
projects used. Like the way I named them above. Now I will have to create
them myself.

Oh well I justed learned Maven and I like it alot :)
--
View this message in context: http://old.nabble.com/How-to-link-native-library-to-a-Maven-Dependency-in-Eclipse--tp26401720p26421016.html
Sent from the Maven Eclipse - User mailing list archive at Nabble.com.
Loading...