LWJGL use in Maven

From LWJGL
Jump to: navigation, search

LWJGL is available in Maven Central Repo starting with the version 2.8.0

You need to add the lwjgl dependency like this

<dependency>
    <groupId>org.lwjgl.lwjgl</groupId>
    <artifactId>lwjgl</artifactId>
    <version>2.8.4</version>
</dependency>

This dependency will get you the main lwjgl.jar and the natives for Windows, Linux and Mac OSX.

The natives dependencies will have a classifier with the form "natives-${OS}" being:

  • natives-windows
  • natives-linux
  • natives-osx

You can use the mavennatives plugin to handle the natives unpacking, this plugin by default seaches for dependencies with classifier like natives-* and unpacks its content to the dir target/natives

<plugin>
        <groupId>com.googlecode.mavennatives</groupId>
        <artifactId>maven-nativedependencies-plugin</artifactId>
        <version>0.0.5</version>
        <executions>
                <execution>
                        <id>unpacknatives</id>
                        <phase>generate-resources</phase>
                        <goals>
                                <goal>copy</goal>
                        </goals>
                </execution>
        </executions>
</plugin>

Adding the plugin like this, will bind it to the maven generate-resources phase, you can also run it manually like "mvn nativedependencies:copy"

This maven plugin can be used with an eclipse plugin that will run it automatically and add the correct java.library.path to your eclipse run configurations but for now it only works with m2eclipse 0.12.* versions.


Example project

There is an example project that uses lwjgl from maven central, when running the "mvn package" command with that project, it will generate a zip file in the target/ dir. This zip file contains the example's main jar, the dependencies, the unpacked natives and batch files so you can run the example in windows, linux and mac.

Other Dependencies

LWJGL Util

<dependency>
    <groupId>org.lwjgl.lwjgl</groupId>
    <artifactId>lwjgl_util</artifactId>
    <version>2.8.4</version>
</dependency>

LWJGL appletloader

<dependency>
    <groupId>org.lwjgl.lwjgl</groupId>
    <artifactId>lwjgl_util_applet</artifactId>
    <version>2.8.4</version>
</dependency>