How to create IProject without Eclipse
I'm trying to mavenize a third part Eclipse's plugin,
but I need to create an instance of IProject to pass at JavaCore.create(instance)
to obtain an instance of IJavaProject.
This application will not have workspace and will b开发者_如何学Ce better that depends from eclipse's libraries as less as I can.
So I can't use:
ResourcesPlugin.getWorkspace().getRoot().getProject(...);
When I try to start my program I have this error report:
Exception in thread "main" java.lang.IllegalStateException: Workspace is closed.
at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:367)
at gr.uom.java.jdeodorant.helpers.JavaProjectHelper.createJavaProject(JavaProjectHelper.java:55)
at gr.uom.java.jdeodorant.refactoring.actions.Index.initializeJavaProject(Index.java:28)
at gr.uom.java.jdeodorant.refactoring.actions.Index.main(Index.java:53)
So is there any way to create this instance outside Eclipse, just passing the path of the project that I need? Some ideas?
The short answer: no.
The workspace requires the OSGi framework to start, and set the osgi.instance.area
property. It also needs some of the other org.eclipse.core.runtime services to be started.
JavaCore.create(*) is in JDT ... parts of org.eclipse.jdt.core might run without having the UI workbench up, but that really depend on which parts.
It might be possible to run a HEADLESS RCP application that includes the org.eclipse.core.runtime and org.eclipse.core.resources (workspace) without including any of the UI components, but you won't be able to use the workspace without starting up OSGi and the core runtime.
精彩评论