Login  Register

Re: Atomic jars in Maven Central - Gradle build system.

Posted by Jesus Zazueta on Jul 11, 2013; 7:27pm
URL: https://forum.jogamp.org/Atomic-jars-in-Maven-Central-Gradle-build-system-tp4029555p4029577.html

io7m wrote
'Lo. It should be fairly easy to add new packages that contain the atomic jars. I left them out initially because I wasn't sure if there was any demand for them with Maven. I'll see what I can do (and we'll test it on the jogamp.org repository first, obviously).

Hello Mark. Jesus here.

Thanks for the info.

I was actually trying to switch over and use these artifacts on Maven Central:

compile 'org.jogamp.gluegen:gluegen-rt-main:2.0.2-rc12'
compile 'org.jogamp.jogl:jogl-all-main:2.0.2-rc12'

However, when testing, I think the native libraries loading mechanism is getting confused by the locations where Gradle placed/cached the actual jars. Specifically, I think the class com.jogamp.common.os.Platform is assuming that all of JOGL's jars are under a single directory, which isn't exactly the case with Gradle.

I'd like to confirm if Maven exhibits this behavior too.

I'll try to describe what's going on in my case (with Gradle) when the gluegen-rt library gets loaded.

When Gradle downloads the artifacts, this is the actual physical location where they land on my machine:

/cygdrive/c/Users/jjzazuet/.gradle/caches/artifacts-24/filestore/org.jogamp.gluegen/gluegen-rt/2.0.2-rc12/jar/1c45dc315d9c36648957f41c875df214d2989a29/gluegen-rt-2.0.2-rc12.jar
/cygdrive/c/Users/jjzazuet/.gradle/caches/artifacts-24/filestore/org.jogamp.gluegen/gluegen-rt/2.0.2-rc12/jar/c013d5e9f359504f5acaec4d7eb87fe2f214fd7/gluegen-rt-2.0.2-rc12-natives-windows-amd64.jar

And when the first static block of Platform runs, it loads gluegen-rt-2.0.2-rc12.jar just fine. But then when it attemps to load gluegen-rt-2.0.2-rc12-natives-windows-amd64.jar:

// load GluegenRT native library
if(_USE_TEMP_JAR_CACHE[0] && TempJarCache.initSingleton()) {
    String nativeJarName = null;
    URI jarUriRoot = null;
    URI nativeJarURI = null;
    try {
        final String jarName = JarUtil.getJarBasename( platformClassJarURI );
        final String nativeJarBasename = jarName.substring(0, jarName.indexOf(".jar")); // ".jar" already validated w/ JarUtil.getJarBasename(..)
        nativeJarName = nativeJarBasename+"-natives-"+PlatformPropsImpl.os_and_arch+".jar";                    
        jarUriRoot = IOUtil.getDirname( JarUtil.getJarSubURI( platformClassJarURI ) );
        nativeJarURI = JarUtil.getJarFileURI(jarUriRoot, nativeJarName);
        TempJarCache.bootstrapNativeLib(Platform.class, libBaseName, nativeJarURI);
    } catch (Exception e0) {
        // IllegalArgumentException, IOException
        System.err.println("Catched "+e0.getClass().getSimpleName()+": "+e0.getMessage()+", while TempJarCache.bootstrapNativeLib() of "+nativeJarURI+" ("+jarUriRoot+" + "+nativeJarName+")");
    }
}

The variable jarUriRoot points to the base path of the first jar, namely:

/cygdrive/c/Users/jjzazuet/.gradle/caches/artifacts-24/filestore/org.jogamp.gluegen/gluegen-rt/2.0.2-rc12/jar/1c45dc315d9c36648957f41c875df214d2989a29/

Which then fails with these messages:

Catched FileNotFoundException: C:\Users\jjzazuet\.gradle\caches\artifacts-24\filestore\org.jogamp.gluegen\gluegen-rt\2.0.2-rc12\jar\1c45dc315d9c36648957f41c875df214d2989a29\gluegen-rt-2.0.2-rc12-natives-windows-amd64.jar (The system cannot find the file specified.), while TempJarCache.bootstrapNativeLib() of jar:file:/C:/Users/jjzazuet/.gradle/caches/artifacts-24/filestore/org.jogamp.gluegen/gluegen-rt/2.0.2-rc12/jar/1c45dc315d9c36648957f41c875df214d2989a29/gluegen-rt-2.0.2-rc12-natives-windows-amd64.jar!/ (file:/C:/Users/jjzazuet/.gradle/caches/artifacts-24/filestore/org.jogamp.gluegen/gluegen-rt/2.0.2-rc12/jar/1c45dc315d9c36648957f41c875df214d2989a29/ + gluegen-rt-2.0.2-rc12-natives-windows-amd64.jar)
NativeLibrary.findLibrary(<gluegen-rt>) (TempJarCache): null
NativeLibrary.findLibrary(<gluegen-rt>, sun.misc.Launcher$AppClassLoader@a4146327) (CL): null
JNILibLoaderBase: loadLibraryInternal(gluegen-rt), TempJarCache: null
JNILibLoaderBase: System.loadLibrary(gluegen-rt) - mode 3
ERROR (retry w/ enumLibPath) - gluegen-rt (Not found in java.library.path)

The version of jgl that I have on the master branch of my repo deals with this problem by finding/extracting/loading the libraries by itself, but it's a very fragile approach compared to the facilities offered by JOGL's classes.

I'm trying to build JOGL from source to see if I can offer a patch to deal with artifacts stored in different locations.

In the meantime, please let me know if there's anything else I could do or specify.

Thank you for your time and help!