【问题标题】:Gradle build with JNI dependencies, application and eclipse plugins使用 JNI 依赖项、应用程序和 Eclipse 插件构建 Gradle
【发布时间】:2013-02-01 21:20:20
【问题描述】:

我正在尝试获取与 Gradle 一起使用的示例 LWJGL 应用程序。 LWJGL 在 lwjgl-platform-2.8.5-natives-windows.jar 等 jar 中有 OpenGL 和 OpenAL 的本机绑定,但是,Gradle 似乎没有认识到这一事实。

应用程序插件的 distZip 任务正确地将所有 jar 文件复制到 zip 中的 lib 目录中,但是,在 .bat 文件中,它仅将上述 natives jar 放在类路径中,它不会将其作为明确的 native 传递给 java .

同样,Eclipse 项目生成也无法设置给定依赖项的“本机库位置”。

是否有任何官方解决方案可以将本机库正确添加到生成的应用程序或 Eclipse 项目中,如果没有,是否有解决此限制的好方法?

我的 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)
    }
}

生成的 zip 分发的内容:

/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

lwjgl-platform-2.8.5-natives-windows.jar 的内容:

META-INF/MANIFEST.MF
lwjgl.dll
lwjgl64.dll
OpenAL32.dll
OpenAL64.dll

【问题讨论】:

    标签: eclipse java-native-interface native gradle lwjgl


    【解决方案1】:

    我一直在解决类似的问题,并已启动 Gradle Natives Plugin 来管理 Java 库的本机依赖项。另请参阅博文“Going Native with Gradle”,我将在其中详细介绍。

    基本上,它会将提供的原生库解包到“natives”构建目录中以供使用和进一步打包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-26
      • 1970-01-01
      • 2021-12-10
      • 2019-08-24
      • 1970-01-01
      • 1970-01-01
      • 2014-06-01
      相关资源
      最近更新 更多