Gradle Dependency Issue

I’m having some issues building my application with Gradle. The dependencies are as defined in the jme3:maven page, everything compiles fine. Additionally, some of the required native libraries are pulled into my project directory at runtime. However, the OpenAL64.dll library is not pulled in, causing the expected ‘can’t load library’ error. Pulling it into the directory manually resolves this error.

My question is: why isn’t this being pulled into my project when I build with Gradle?

Can you share your dependencies + repository sections from your build.gradle ?

You can see one of mine at

Sure:

repositories {
    mavenCentral()
    maven {
        url 'http://updates.jmonkeyengine.org/maven'
    }
}
def scalalibrary_version = '2.11.6'
def jmonkeyengine_version = '3.0'
dependencies {
    compile "org.scala-lang:scala-library:$scalalibrary_version"
    compile "com.jme3:jme3-core:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-effects:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-networking:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-plugins:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-jogg:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-terrain:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-blender:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-jbullet:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-niftygui:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-desktop:$jmonkeyengine_version.+"
    compile "com.jme3:jme3-lwjgl:$jmonkeyengine_version.+"
    runtime "com.jme3:jme3-lwjgl:$jmonkeyengine_version.+"
}

It’s almost identical to the jme3:maven page (with the addition of a scala compiler and the runtime lwjgl library). Also, I haven’t noticed any difference in output with the runtime lwjgl library - some native libraries are included without it.

adding a lib in runtime is useless, because every lib from ‘compile’ configuration are included into ‘runtime’ configuration.
0. Can you share, the full log, Stacktrace of the error ?

  1. Can you check that the lwjgl-natives-2.9.0.jar is in your dependencies ‘gradle dependencies’ or something like that
  2. Can you check that the file windows/OpenAL64.dll into the lwjgl-natives-2.9.0.jar you used
  3. How do you launch the application.

FYI to launch from gradle you can use :

  • plugin ‘application’ + ‘gradle run’
  • OR a task like
task exec(type:JavaExec) {
      main = System.getProperty("exec.mainClass") ?: "sandbox.Main"
      classpath = sourceSets.test.runtimeClasspath
}

Sure. The error is a standard unable to load library error, here’s the stack trace:

Jul 01, 2015 1:20:26 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
SEVERE: Failed to load audio library
org.lwjgl.LWJGLException: Could not locate OpenAL library.
    at org.lwjgl.openal.AL.create(AL.java:151)
    at org.lwjgl.openal.AL.create(AL.java:102)
    at org.lwjgl.openal.AL.create(AL.java:201)
    at com.jme3.audio.lwjgl.LwjglAudioRenderer.initInThread(LwjglAudioRenderer.java:140)
    at com.jme3.audio.lwjgl.LwjglAudioRenderer.run(LwjglAudioRenderer.java:98)
    at java.lang.Thread.run(Thread.java:745)

That jar is indeed in my gradle dependencies folder and it does include the OpanAl64.dll file (that’s the file that I pulled manual).

I’m running it with gradle’s application plugin (gradle run).

OK, next batch of questions :

  • does any dll is extracted into the current dir ?
  • does the current dir constains some special characteres (accent, space, …) ?
  • do you have some audio output connecter (head phone, speaker), iirc I’d got an issue on some windows becaus it disable audio if no output connected.

Yeah, there are other dlls that get pulled in (including the lwjgl natve library). No special characters in the folder name and there are speakers connected.

which dll ?

It pulls in jinput-dx8_64.dll, jinput-raw_64.dll, and lwjgl64.dll.

Sorry I have no more idea, can you share the project (at least privately), so I can try to reproduce it (I have linux64 and win32, so no win64, but you’ll know if it’s a environement issue or not).

Hm i run a gradle build on windows, and never had problems with missing dll.

Since you compile yourself, you could sprinkle the jmonkeyengine/NativeLibraryLoader.java at master · jMonkeyEngine/jmonkeyengine · GitHub class with system outs to see what it tries to do.
Maybe the issues can be tracked from there.

Ah! Yeah. I compiled it on an old laptop (Mac) and everything is fine. I’m not sure what might be wrong with this particular environment… But, at least I know that it’s not Gradle nor the project.

Thanks for all the help.