The Impaler
The Impaler

Reputation: 48850

Eclipse plugin saving metadata

I'm writing an Eclipse plugin and I need to save some properties files and binary files as metadata of the plugin. The idea is that when the user starts Eclipse next day he/she won't need to configure/type all again from scratch.

I'm good about writing and reading the files, but I'm not sure about the best location for them. It seems like the perfect location would be something like:

<WORKSPACE_HOME>/.metadata/.plugins/org.myplugin.name

But how do I get or assemble this path? So far I've got to assemble this path as shown below:

Is it possible to get that path without hard coding values?

Do I need to create the last directory (my plugin name)? (I guess I need to)

Upvotes: 0

Views: 321

Answers (1)

nitind
nitind

Reputation: 20003

Ask org.eclipse.core.runtime.Platform for your Bundle's "private" state location. If you have a plug-in activator, you can get the Bundle from there. Otherwise, there's a different method on Platform to get the right instance based on the ID.

https://help.eclipse.org/oxygen/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/Platform.html#getStateLocation-org.osgi.framework.Bundle-

Upvotes: 2

Related Questions