I’m developing an app using JOGL on Windows. I’ve been using Eclipse thus far but I have started writing a corresponding Maven POM file so I can automatic the build and packaging steps.
JOGL is not actively maintained in Maven so I have written a small script that imports the jars via install:install-file into my local repository :
set JOGL_VER=2.0
set JOGL_HOME=./jogl
set JOGL_LIB=%JOGL_HOME%/jar
set MVN_INSTALL=call mvn install:install-file
%MVN_INSTALL% -DgroupId=org.jogamp.gluegen -Dfile=%JOGL_LIB%/gluegen-rt-natives-windows-i586.jar \
-DartifactId=gluegen-rt-natives-windows-i586 -Dversion=%JOGL_VER% -Dpackaging=jar
%MVN_INSTALL% -DgroupId=org.jogamp.gluegen -Dfile=%JOGL_LIB%/gluegen.jar \
-DartifactId=gluegen -Dversion=%JOGL_VER% -Dpackaging=jar
%MVN_INSTALL% -DgroupId=org.jogamp.jogl -Dfile=%JOGL_LIB%/jogl-all-natives-windows-i586.jar \
-DartifactId=jogl-all-natives-windows-i586 -Dversion=%JOGL_VER% -Dpackaging=jar
%MVN_INSTALL% -DgroupId=org.jogamp.jogl -Dfile=%JOGL_LIB%/jogl-all.jar
-DartifactId=jogl-all -Dversion=%JOGL_VER% -Dpackaging=jar
This results in the following files in my repo
.m2\repository\org\jogamp\gluegen\gluegen\2.0\gluegen-2.0.jar
.m2\repository\org\jogamp\gluegen\gluegen\2.0\gluegen-2.0.pom
.m2\repository\org\jogamp\gluegen\gluegen-rt-natives-windows-i586\2.0\gluegen-rt-natives-windows-i586-2.0.jar
.m2\repository\org\jogamp\gluegen\gluegen-rt-natives-windows-i586\2.0\gluegen-rt-natives-windows-i586-2.0.pom
.m2\repository\org\jogamp\jogl\jogl-all\2.0\jogl-all-2.0.jar
.m2\repository\org\jogamp\jogl\jogl-all\2.0\jogl-all-2.0.pom
.m2\repository\org\jogamp\jogl\jogl-all-natives-windows-i586\2.0\jogl-all-natives-windows-i586-2.0.jar
.m2\repository\org\jogamp\jogl\jogl-all-natives-windows-i586\2.0\jogl-all-natives-windows-i586-2.0.pom
Note that since I specified 2.0, the files get suffixed with 2.0, e.g. gluegen-rt-natives-windows-i586-2.0.jar.
But now I want to use the exec:java command to run the app after a build, to ensure it functions i.e.
mvn exec:java
So I add the exec-maven-plugin to my pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.testapp.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
And I also add the dependencies to JOGL. Not that the native binaries are scoped runtime since I don’t need them at compile time:
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-natives-windows-i586</artifactId>
<version>2.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-natives-windows-i586</artifactId>
<version>2.0</version>
<scope>runtime</scope>
</dependency>
But when I run this, I get the following error
Catched FileNotFoundException: C:\Users\xxx\.m2\repository\org\jogamp\gluegen\gluegen\2.0\gluegen-2.0-natives-windows-i586.jar (
The system cannot find the file specified), while TempJarCache.bootstrapNativeLib() of jar:file:/C:/Users/xxx/.m2/repository/org
/jogamp/gluegen/gluegen/2.0/gluegen-2.0-natives-windows-i586.jar!/ (file:/C:/Users/xxx/.m2/repository/org/jogamp/gluegen/gluegen
/2.0/ + gluegen-2.0-natives-windows-i586.jar)
[WARNING]
The issue is therefore straightforward. I installed the jars via install:install-file and the version 2.0 was appended after the artifact id e.g. gluegen-rt-natives-windows-i586-2.0.jar, but the exec:java expects the jar to be called gluegen-2.0-natives-windows-i586.jar.
Since the project builds I must assume the compile phase is correctly looking for the jar files using the expected file name, but exec is not.
Why is it dumping the version number in the middle of the artifact id and how do I make it work properly? The artifact id is named according to convention so I don’t understand why it would be split like this.
Exec:java has nothing to do with your problem.
JOGL itself has some sort of complex internal mechanism for managing native code via JNI, and that mechanism makes assumptions about file names which are incompatible with the Maven rules for naming files in the repository.
You’re going to have to use the maven-assembly-plugin to copy the dependencies to a tree that has the names and shapes required by JOGL and execute from there, or find a way to reconfigure JOGL to tolerate Maven naming conventions.