Xtext Project: Add Jar Libraries with the Project Wizard Manager into the Classpath/Referenced Libaries of the clients Project

你离开我真会死。 提交于 2019-12-06 13:09:38

Assuming that you are talking about plain Java projects (no Eclipse Plugin projects or Maven/Gradle projects), you can create a classpath container (similar to the "JRE System Library" container that exists in every Java project).

A working, easily accessible example is the Xtend Library container

The essential steps are:

  1. You turn your library into an Eclipse plugin, which you make part of your DSL feature
  2. In your UI plugin, you create an implementation of IClasspathContainer that uses the Eclipse plug-in mechanisms to retrieve the location of the JAR file
  3. You create a subclass of ClasspathContainerInitializer that creates an instance of your IClasspathContainer implementation
  4. You create a small IClasspathContainerPage wizard page for users to add your library using the Java Build Path -> Libraries page in the project settings
  5. You register everything in your UI project's plugin.xml using the org.eclipse.jdt.core.classpathContainerInitializer and org.eclipse.jdt.ui.classpathContainerPage extension points

In the Xtend UI, you'll also find some extensions, e.g. a quick fix for adding the libraries (which also handles the case of Eclipse plugin projects as client projects).

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