How to run JUnit with Gradle and JOGL 2.3.x native libraries?


(JayB) #1

I’m trying to use Gradle to build an application that uses JOGL (2.3.x). For JOGL2.3.x, there is several jar files needed which are ordered as following:

  • java-class-files.jar (for instance: gluegen-rt-2.3.x.jar)
  • natives-libraries.jar (for instance: gluegen-rt-native-2.3.1-win-amd64.jar)

The JOGAMP web site indicates:
(http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL)

  • Either the jar containing the java classes and the one containing the natives libraries have to be in the same folder.
  • Either we can extract the native libraries and add it to the library path.

Gradle downloads these jars files form artifactory, so each of them is located at a different cache folder. So when I’m trying to run the test task from Gradle, the native libraries are not found.

So, I finally tried to configure the env. variable java.library.path. by setting it with the path of where the native libraries are located. To do that I wrote the following code (which works):

tasks.withType(Test) {
dependsOn “:unzipNativeLibrariesContainedInJar

         // set a system property for the test JVM(s)
        systemProperty "**java.library.path**", **ldLibrariesFolder**.absolutePath

}

The unzipNativeLibrariesContainedInJar unzip the JOGL native libraries (gluegen-rt.dll for instance) in the folder ldLibrariesFolder. Everything is copied in this folder and this folder is added in the java.library.path but I still have the problem: the the gluegen-rt.dll is not found. Indeed, the gluegen-rt.dll is searched in the subproject folder instead of the ldLibrariesFolder when I launch the test task from gradle.

Maybe I missed something and a support would be really appreciated.
Any Idea?