Reputation: 13
I am currently working on a little Eclipse plugin and I have to deal with the classic 'plugin.xml' stuff, such as the creation of a nature:
<extension
id="aplugin.natures.MyNature.NATURE_ID.id"
name="Sample Project Nature"
point="org.eclipse.core.resources.natures">
Now in this particular example, I must, somewhere in my plugin code, give this 'id' as a String to some Eclipse function. So I need to create a specific class like:
package aplugin.natures;
public class MyNature implements IProjectNature {
public static final String NATURE_ID = "aplugin.natures.MyNature.NATURE_ID.id"; //$NON-NLS-1$
}
And here comes my problem, I got some copy and paste of my 'id'. I must admit that I am not very proud of it.
So my question is, does someone know a way to use the 'NATURE_ID' field in the 'MyNature' class directly in the 'plugin.xml' file ?.
In the end I wish to write something like:
<extension id="${aplugin.natures.MyNature.NATURE_ID}" ... >
Upvotes: 1
Views: 248
Reputation: 12718
That is not possible by design.
The idea is that the Eclipse core can load the plugin.xml
files for all resolved plug-ins/bundles without loading/activating the plug-ins. Resolving your construct above would normally require Eclipse to resolve all references for the class - MyNature
in this case - which can easily lead to the activation of many other dependent plug-ins. Not good.
So - by design - all data in plugin.xml
must be self-contained. (With the possible exception of localized strings).
Upvotes: 3