Gradle如何添加原生依赖?[Libgdx]

2023-03-02Java开发问题
2

本文介绍了Gradle如何添加原生依赖?[Libgdx]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个默认的 Libgdx Gradle 设置,我需要向其中添加我的简单文本渲染库.它由一个 .jar 文件和本机 lib 文件组成.

I have a default Libgdx Gradle setup, and I need to add my simple text rendering library to it. It consists of a .jar file and native lib file.

这行 build.gradle 脚本似乎可以正常工作,它的作用是将 jfreetype.jar java 库添加到我的构建路径中.

This line of build.gradle script seems to work as I would expect, and what it does is add jfreetype.jar java library to my build path.

compile files('../local_lib/jfreetype.jar')

是否有像这样的魔术命令来添加我的文件系统上可用且未 Maven 化的本机库(准确地说是 .dll)?

Is there a magic command like this to add native library (.dll to be exact) that is available on my file system and is not Mavenized?

natives "../local_lib/jfreetype32.dll"

这行代码只是给了我一个错误,说在某个 repo 中找不到某些东西.我想应该有一条像 .jar 文件这样的神奇行来添加仅在我的文件系统上可用而不在某些 repo 上可用的本机文件.

This line of code just gives me an error saying that something cannot be found at some repo. I guess there should be a magical line like with .jar file to add native files that are available only on my file system and not on some repo.

推荐答案

Gradle Natives 插件应该做你想做的事.您可以指定指向包含本机 dll/so 的 jar 文件的配置.然后,一个 gradle 任务unpackNatives"会将 dll/so 解压到构建目录中.

The Gradle Natives plugin should do what you want. You can specify a configuration that points at jar files that contain native dll/so. A gradle task "unpackNatives" will then unpack the dll/so into the build dirs.

根据您启动应用程序的方式,您可能仍需要告诉 Java 运行时在哪里可以找到 dll/so.在项目网站上有一些关于它是如何工作的信息:

Depending upon how you launch your application, you may still need to tell the Java runtime where to find the dll/so. There is some info about how this works at the project website:

https://github.com/cjstehno/gradle-natives

这篇关于Gradle如何添加原生依赖?[Libgdx]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13