1
\$\begingroup\$

I am trying to use Maven to manage building my LWJGL projects. The entire project needs to be packed into a single executable jar, dependencies, natives and resources included, so that can be easily distributed. I have been using JarSplice to do this until now.

Is it possible to do the same with Maven?

My attempts thus far have failed: either the main class/natives could not be located or OpenAL would crash when I tried to execute the jar file.

My current pom.xml is below:

<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">

<modelVersion>4.0.0</modelVersion>
<groupId>Sidian</groupId>
<artifactId>LWJake2</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>LWJake2</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <mainClass>Main</mainClass>

    <lwjgl.version>2.9.3</lwjgl.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.lwjgl.lwjgl</groupId>
        <artifactId>lwjgl</artifactId>
        <version>${lwjgl.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
    </plugins>
</build>

\$\endgroup\$
3
  • \$\begingroup\$ Van you add you pom.xml to the question? \$\endgroup\$
    – Verhagen
    Oct 19, 2015 at 17:25
  • \$\begingroup\$ This has nothing to do with GameDevelopment at all (You could replace LWJGL with any other lib and still have the same problem). But something to google for: maven uber jar \$\endgroup\$
    – tkausl
    Oct 20, 2015 at 13:45
  • \$\begingroup\$ Thank you for answering my game related question, I will be sure to check it out \$\endgroup\$ Oct 22, 2015 at 7:40

1 Answer 1

2
\$\begingroup\$

This is the plugin you need

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>your.main.class.Here</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
\$\endgroup\$
1
  • 1
    \$\begingroup\$ This answer would be even better if it explained why this answer works, or how the user can follow the strategy you used to determine the right markup to use. \$\endgroup\$
    – DMGregory
    Jan 13, 2019 at 13:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .