Gradle 和 Lwjgl 3 个当地人

Gradle and Lwjgl 3 Natives

我是 gradle 的新手,我正在尝试使用 lwjgl3 配置 gradle。因为我没有找到托管 lwjgl3 的存储库,所以我决定使用该项目的每个人都必须定义 lwjgl 库的路径。我创建了一个 user.gradle 文件,其中包含 jar 和 natives 的路径。

我的 build.gradle 目前是这样的。

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'
}

如何设置本地人?我尝试了不同的方式。 Google 这次没帮我。所有结果都与该库的旧版本相关,并且都在使用存储库。也许我只见中间的树木而错过了森林。有什么想法吗?

此致!

PS:不确定它是否重要:我们在 Windows、Linux 和 [=33 上使用不同的 IDE,例如 intelliJ 和 Eclipse =].

我 运行 遇到了同样的问题,并编写了一个插件来处理与 Java jar 文件关联的本地人。

http://cjstehno.github.io/gradle-natives/

它将从 jar 文件中解压缩它们,以便您可以使用它们并将它们部署到您的项目中。

帮我解决了问题。的问题是我不知道如何配置 gradle 来使用本地人。通常我在 运行 配置中设置类路径。然而:

如何使用 gradle 设置类路径的非常简单的解决方案:

应用java插件并使用函数:

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

通过 gradle 简单地 运行 您的应用程序,它应该可以工作。

通过搜索 "lwjgl gradle natives" 找到了太多解决方案,我没有找到合适的 :-)

希望解决方案对某人有所帮助。