eclipse - 使用片段修补/合并插件中的plugin.properties文件

标签 eclipse plugins merge patch fragment

在我的插件 de.support.help 中是plugin.properties 文件。 这些属性文件包括首选项页面的字符串。

我想为不同的客户使用此插件,但客户名称位于属性文件内。

我想使用 Eclipse 片段机制来修补属性文件。据我所知,片段插件可以在运行时修补相应的插件。

我在插件 de.support.help 中有文件plugin.properties,其中包含该行

plugin.name = Copyright XYZ

我确实有 fragemt de.support.help.fragment,其中包含带有行的文件plugin.properties

plugin.name = Copyright ABC

我希望在运行时显示字符串“Copyright ABC”,但事实并非如此。我很久以前就用java类进行了相同的测试,我记得它是有效的。片段中的 java 代码已放置到原始插件中。

你有什么想法来处理这个问题吗?还是我误解了片段机制?

谢谢

编辑:

当我从 de.support.help 插件中删除plugin.properties 文件时,它会按预期工作。片段文件被复制到插件目录中并在运行时使用。

或者我必须修补 somce eclipse 类 Can_fragments_be_used_to_patch_a_plug

最佳答案

根据How to Internationalize your Eclipse Plug-In文章

A plug-in fragment provides additional functionality to its target plug-in.
At runtime, these plug-in contributions are merged along with all dependent fragments.

These contributions can include code contributions and contributions of resources associated with a plug-in, like property and HTML files.

In other words, the plug-in has access to the fragment's contents via the plug-in's classloader.

The Eclipse Platform merges plug-in fragments in a way that the runtime elements in the fragment augment the original targeted plug-in.
The target plug-in is not moved, removed, or modified in any way.

Since the fragment's resources are located by the classloader, the plug-in developer has no need to know whether resources are loaded from the plug-in's JAR file or one of its fragments' JAR files.


我怀疑 classLoader 在 de.support.help.fragment 之前先检测到 de.support.help 插件中的 plugin.name片段。

目前,我不确定是否可以完成,因为之前已经尝试过(对于 Eclipse CheckStyle plugin ),但没有取得多大成功。

关于eclipse - 使用片段修补/合并插件中的plugin.properties文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/657756/

相关文章:

安卓字体变化

java - eclipse 和 JAR 中的资源位置差异问题

plugins - IntelliJ IDEA : install plugins from command line

ruby-on-rails - 从 Git 存储库安装 Rails 插件

c - 警告的可能解决方案

java - 在 Eclipse 控制台中显示 Grizzly 异常

javascript - 未捕获的类型错误 : Cannot set property 'plugin' of undefined

eclipse - 如何使用 Subclipse 在 Eclipse 中从分支合并到主干?

java - 在 Java 中让一个 Integer 指向 3 个有序列表

python - Python3中合并k个排序列表,内存和时间之间的权衡问题