How to create IProject without Eclipse

随声附和 提交于 2019-12-24 07:06:12

问题


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 be 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?


回答1:


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.



来源:https://stackoverflow.com/questions/6214202/how-to-create-iproject-without-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!