问题描述
我一直在搜索很多这个问题,但是我找不到正确的解决方案或者如何管理这个问题。
I have been searching quite a lot for this problem, however I can't really find a proper solution or a how-to manage this one.
我有写了一个简单的DSL,通过Xtext和Xtend生成一些代码。我可以在Xtext的UI项目中使用项目向导,以便为我的语法和插件创建一个单独的项目。我能够轻松创建项目,但是我仍然需要在客户端项目的类路径中添加一些重要的依赖项。这似乎有点更棘手,特别是如果.jar的路径不是绝对的。
I have written a simple DSL for generating some code via Xtext and Xtend. I optionally use the project wizard in the UI project of Xtext to be able to create an individual project for my grammar and plugin. I am able to create the project with ease, however I still need to add some important dependencies into my class path of the clients project. It seems to be a bit more tricky especially if the path of the .jar is not absolute.
这可能是很明显的解决。
This is probably pretty obvious to solve though.
欣赏任何帮助!谢谢:)
Appreciate any help!! Thank you :)
推荐答案
假设您正在谈论纯Java项目(没有Eclipse插件项目或Maven / Gradle项目)您可以创建一个类路径容器(类似于每个Java项目中存在的JRE System Library容器)。
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
基本步骤是:
- 进入Eclipse插件,您可以将其作为DSL功能的一部分
- 在您的UI插件中,您将创建一个使用
IClasspathContainer
的实现Eclipse插件机制来检索JAR文件的位置 - 您创建一个
ClasspathContainerInitializer
的子类,创建一个您的IClasspath容器
实现 - 您创建一个小的
IClasspathContainerPage
向导页面,供用户使用Java Build添加库路径 - >项目设置中的库页面 - 您可以使用和扩展点
- You turn your library into an Eclipse plugin, which you make part of your DSL feature
- 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 - You create a subclass of
ClasspathContainerInitializer
that creates an instance of yourIClasspathContainer
implementation - You create a small
IClasspathContainerPage
wizard page for users to add your library using the Java Build Path -> Libraries page in the project settings - You register everything in your UI project's plugin.xml using the
org.eclipse.jdt.core.classpathContainerInitializer
andorg.eclipse.jdt.ui.classpathContainerPage
extension points
在Xtend UI中,您还可以找到一些扩展名,例如a ,用于添加库(也可以处理Eclipse插件项目作为客户端项目)
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).
这篇关于Xtext项目:将Jar库与Project Wizard Manager一起添加到客户端Project的Classpath / Referenced Libaries中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!