I wrote an Eclipse-Plug-In (for use in a headless Eclipse application) to import existing Eclipse projects programmatically into a Eclipse Workspace using this solution and it works fine.
The only problem I'm facing is that all these projects do not have "Git nature" (all projects are in the same Git repository) after opening the workspace with Eclipse IDE. This seems related to this question. So my question is:
What code do I have to add to my Plug-In to add "Git nature" programmatically? How can I call "Share Project" operation programmatically?
I observed that closing and reopening an imported project after opening the workspace with an Eclipse IDE added the "Git nature" to the project. During "Open project" operation on the status bar something like "Auto share..." appeared as message. So I added the following line to my Eclipse Plug-In right before the import operation is called:
InstanceScope.INSTANCE.getNode("org.eclipse.egit.core").putBoolean(GitCorePreferences.core_autoShareProjects,
true);
This line enables "Auto share" option from "Preferences -> Team -> Git -> Projects" (see also this question) but it didn't change anything, even after adding code to close and reopen the importing projects after the import operation.