如何使用 Maven 处理跨平台(Windows + Linux)Java Native Interface 项目?
我目前正在尝试开发一个跨平台解决方案,该解决方案将使一些尚未属于 java 标准库的 UI 组件可用于我的 java 代码。我正在为 X11 编写 xlib 代码,并使用适用于 Windows 的相关 win32 api。
是否可以(甚至推荐?)使用 Maven 设置 java 和 c 代码构建系统?我需要一个构建系统来编译和链接 X11 代码,编译和链接 win32 代码,并将它们与 java 接口代码一起打包在 jar 中。我应该使用 Ant 来做到这一点吗?
我以前使用过这两种构建工具,但我不知道哪一个被认为是 JNI 代码的推荐工具。
I am currently trying to develop a cross-platform solution that will make some UI components that are not already part of the java standard library available to my java code. I am writing xlib code for X11 and using the relevant win32 api's for windows.
Is it possible (or even recommended?) to setup a java and c code build system using Maven? I need a build system that will compile and link the X11 code and compile and link the win32 code and package them in the jar along with the java interface code. Should I be using Ant to do this?
I have used both build tools before but I don't know which is considered the recommended tool for JNI code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 native-maven-plugin。我将创建一个多模块 Maven 项目,为每个本机接口提供单独的模块。
It is certainly possible using the native-maven-plugin. I would create a multi-module maven project with separate modules for each of the native interfaces.
这是可能的并且没有禁忌。我会使用 Native Maven 插件 或 < a href="http://mojo.codehaus.org/cbuild-parent/cbuild-plugin-parent/make-maven-plugin/index.html" rel="nofollow noreferrer">Makefile 编排插件(如果你有一个现有的makefile),带有特定的模块或配置文件对于每个目标平台。
It is possible and not contraindicated. I would use the Native Maven Plugin or the Makefile Orchestration Plugin (if you have an existing makefile), with specific modules or profiles for each targeted platform.