Reputation: 1724
I'm trying to get a sample LWJGL application working with Gradle. LWJGL has native bindings for OpenGL and OpenAL, in the jar lwjgl-platform-2.8.5-natives-windows.jar and such, however, Gradle does not seem to recognize this fact.
The application plugin's distZip task properly copies all jar files into the lib directory in the zip, however, in the .bat file, it only puts the aforementioned natives jar on the classpath, it does not pass it to java as explicitly native.
Similarly, the Eclipse project generation also fails to set the "native library location" of a given dependency.
Is there any official solution to properly add native libraries to generated applications or Eclipse projects, and if not, is there any nice hack around this limitation?
My gradle.build:
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
sourceCompatibility = 1.7
mainClassName = 'org.lwjgl.examples.Game'
repositories {
mavenCentral();
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: 'latest.release'
compile group: 'org.apache.commons', name: 'commons-lang3', version: 'latest.release'
compile group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: 'latest.release'
testCompile group: 'com.jayway.awaitility', name: 'awaitility', version: 'latest.release'
testCompile group: 'junit', name: 'junit', version: 'latest.release'
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: 'latest.release'
testCompile group: 'org.mockito', name: 'mockito-core', version: 'latest.release'
}
jar {
baseName = rootProject.name
version = System.env['BUILD_NUMBER']
version = version == null ? 0 : version
manifest {
attributes("Implementation-Title": baseName, "Implementation-Version": version)
}
}
Contents of generated zip distribution:
/lib//bin/tyle
/lib//bin/tyle.bat
/lib/commons-lang3-3.1.jar
/lib/guava-14.0-rc2.jar
/lib/jinput-2.0.5.jar
/lib/jinput-platform-2.0.5-natives-linux.jar
/lib/jinput-platform-2.0.5-natives-osx.jar
/lib/jinput-platform-2.0.5-natives-windows.jar
/lib/jutils-1.0.0.jar
/lib/lwjgl-2.8.5.jar
/lib/lwjgl-platform-2.8.5-natives-linux.jar
/lib/lwjgl-platform-2.8.5-natives-osx.jar
/lib/lwjgl-platform-2.8.5-natives-windows.jar
/lib/tyle-0.jar
Contents of lwjgl-platform-2.8.5-natives-windows.jar:
META-INF/MANIFEST.MF
lwjgl.dll
lwjgl64.dll
OpenAL32.dll
OpenAL64.dll
Upvotes: 2
Views: 6112
Reputation: 13984
I have been working against similar issues and have started a Gradle Natives Plugin for managing the native dependencies of Java libraries. See also a blog post "Going Native with Gradle" where I go into more details.
Basically it unpacks the provided native libraries into a "natives" build directory for use and further packaging.
Upvotes: 5