A solution to native dependencies with Maven

Started by ruben01, July 04, 2009, 22:36:15

Previous topic - Next topic

ruben01

Hi,
    I'm working with a friend on a set of tools to solve the problem of having native dependencies.

We made a maven plug-in, than unpacks the native dependencies declared in the pom. You mark a dependency as being native, by using a classifier like "natives-*"

for example:
<dependency>
    <groupId>lwjgl</groupId>
    <artifactId>lwjgl</artifactId>
    <version>2.1.0</version>
    <classifier>natives-linux</classifier>
</dependency>


this declares a dependency on a jar which contains the natives for Linux 32 and 64 bits.

what the plug-in does is unpack every dependency (declared or transitive) of your project in a directory (by default in target/natives)

then you can for example, use the assembly plug-in to add the content of the natives dir to a zip file to make your distribution. or use the original jars and reference them in a jnlp to make an applet or webstart distribution.


this solves (we think) using native dependencies directly from maven, but leaves the integration with your ide for another plug-in.


We also made a plug-in for eclipse, that extends m2eclipse (plug-in for using maven with eclipse) and executes our maven plug-in to unpack the native dependencies, and configures your classpath to automatically so that when you run a class, it works without manual configuration.



Using both these plug-ins you can work as if the native dependencies where no different from any other dependency.


Of course to make this work you need to have the native dependencies packed in a jar, and deployed in some repository with a classifier with the format we define.  Ideally they should be deployed in the central maven repository,  but for now, you can install them locally or to a remote repository that you control, like nexus, archiva, artifactory etc.

This post is only the presentation, detailed instructions are available at our project's homepage (http://code.google.com/p/mavennatives/)

In our homepage there is an example project that uses our maven plug-in to use lwjgl.

It would be great if you could try this, or at least comment if you think our approach is not right.