Gradle and Lwjgl 3 Natives

H3ADLESS

I'm new to gradle and I'm trying to configure gradle with lwjgl3. Because I didn't found a repo where lwjgl3 is hosted i decided that everybody who use this project has to define the path to the lwjgl lib. I created a user.gradle file with contains the paths to the jar and to the natives.

My build.gradle looks like this at the moment.

apply plugin: 'java'
apply from: 'user.gradle'
apply plugin: 'application'

sourceCompatibility = 1.8
targetCompatibility = 1.8

mainClassName = "mp.Main"

println("LWJGL jar path is configured to: ${config.lwjgl3Jar}")
println("LWJGL natives path is configured to: ${config.lwjgl3Natives}")

repositories {
    mavenCentral()
    flatDir {
        dir config.lwjgl3Jar
    }
}

dependencies {
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'net.java.dev.jna:jna:4.1.0'
    testCompile 'junit:junit:4.+'
    testCompile 'com.carrotsearch:junit-benchmarks:0.7.2'
    compile name: 'lwjgl'
}

tasks.withType(Test) {
    scanForTestClasses = false
    include "**/*Test.class" // whatever Ant pattern matches your test class files
}

sourceSets{
    main {
        java {
            srcDir 'src'
            exclude 'mp/graphics/gl/scene/Mesh.java'
            exclude 'test'
        }
    }

    test{
        java {
            srcDir 'src/test'
            exclude '**/UnsafeTest.java'
            exclude '**/DispatchTests/*'
            exclude '**/MemoryTest.java'
            exclude '**/SuperFastListTest.java'
            exclude '**/MatrixTest.java'
            exclude '**/SimulationTest.java'
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

How to set the natives? I tried it different ways. Google didn't helped me out this time. All results are related to older versions of this lib and all are using repositories. Maybe I'm missing the forest for the trees in between. Any ideas?

Best regards!

PS: Not sure if it is important: We are using different IDE's like intelliJ and Eclipse on Windows, Linux, and Mac.

H3ADLESS

I solved the problem for me. The problem for was that I didn't knew how to configure gradle to use the natives. Normally I set the the classpath in the run config. However:

The very simple solution how to set the classpath with gradle:

Apply the java plugin and use the function:

run {        
    systemProperty 'java.library.path', 'path to ur natives')
}

The simply run your application via gradle and it should work.

There were so many solutions by searching for "lwjgl gradle natives" that I didn't found the right one :-)

Hope the solution helps somebody.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related