将 Maven tycho-p2-plugin 与 SWT 一起使用
如何使用 Eclipse P2 存储库和 Maven tycho-p2-plugin 构建 SWT 应用程序?
How do I build an SWT application using the Eclipse P2 repository and the Maven tycho-p2-plugin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第谷允许您构建和构建编译基于 eclipse 的东西,包括插件、功能和 RCP 应用程序。在官方项目页面上有很多很好的教程,但就我而言,我使用了示例项目( http://git.eclipse.org/c/tycho/org.eclipse.tycho-demo.git/tree/itp04-rcp )。
但是,如果您不需要构建一些插件或 RCP 应用程序,我认为您不需要 tycho:您只需导入 SWT 作为普通的 Maven 依赖项并以这种方式构建您的应用程序...
Tycho allows you to build & compile eclipse-based stuff, including plugins, features, and RCP applications. On the official project page there are a tons of good tutorial, but in my case I used the sample project ( http://git.eclipse.org/c/tycho/org.eclipse.tycho-demo.git/tree/itp04-rcp ).
However, if you do not need to build some plugins or a RCP application, I think you do not need tycho: you just can import SWT as a normal maven dependency and build your app that way...
我发现了问题。背景:我正在构建 Xtext 为 DSL 生成的编辑器插件。
该插件依赖于
org.eclipse.swt;version=3.7.0
。打包
是eclipse-plugin
。我列出了我的父 POM 中的所有必要环境。p2 存储库是我硬盘上的本地镜像,我通过导出目标定义(*.target 文件)来填充它。
问题是导出目标定义将创建看起来很像 p2 存储库的东西,但存在细微的差异。
例如,您必须在目标定义文件中定义目标环境(Linux/Windows/Mac、x86/x86_64、win32/cocoa/gtk)。如果您不指定任何内容,Eclipse 将使用当前平台。如果使用“*”,则所有 SWT 片段都将被省略。
这意味着:导出包含所有 SWT 片段(
plugins/
文件夹中的 30 个插件),它们在contents.jar
中提到但是artifact.jar
仅列出与您当前平台匹配的单个 SWT 片段(即捆绑包加上源代码)。这对第谷来说还不够。
解决方案:使用以下小脚本创建正确的 p2 存储库:
在正常运行的 Eclipse 安装中运行此脚本。
I found the problem. Background: I'm building the editor plugin which Xtext generates for DSLs.
The plugin depends on
org.eclipse.swt;version=3.7.0
. Thepackaging
iseclipse-plugin
. I'm listing all the necessary environments in my parent POM.The p2 repository is a local mirror on my hard disk which I fill by exporting a Target Definition (*.target file).
The problem is that exporting a Target Definition will create something that looks a lot like a p2 repo but there are subtle differences.
For example, you have to define a target environment (Linux/Windows/Mac, x86/x86_64, win32/cocoa/gtk) in the Target Definition file. If you don't specify anything, Eclipse will use the current platform. If you use "*", all SWT fragments will be omitted.
This means: The export contains all the SWT fragments (30 plugins in the
plugins/
folder), they are mentioned in thecontents.jar
but theartifact.jar
only lists the single SWT fragment which matches your current platform (i.e. the bundle plus the sources).This is not enough for Tycho.
Solution: Create a proper p2 repo using this small script:
Run this inside of a working Eclipse installation.
您可以定义“target-platform-configuration”插件的目标环境。无论您正在为多个环境构建 RCP 或功能,您都可以让您的功能包含这些主机的 swt 片段。
feature.xml 中的片段
You can define the target environments for 'target-platform-configuration' plugin. Whatever you are building RCP or features for multiple environments, you can let your feature to include the fragments of swt for these hosts.
Snippet in feature.xml