Xtext项目:将Jar库与Project Wizard Manager一起添加到客户端Project的Classpath / Referenced Libaries中 [英] Xtext Project: Add Jar Libraries with the Project Wizard Manager into the Classpath/Referenced Libaries of the clients Project

查看:157
本文介绍了Xtext项目:将Jar库与Project Wizard Manager一起添加到客户端Project的Classpath / Referenced Libaries中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索很多这个问题,但是我找不到正确的解决方案或者如何管理这个问题。

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).

一个工作很容易访问的示例是 Xtend库容器

A working, easily accessible example is the Xtend Library container

基本步骤是:


  1. 进入Eclipse插件,您可以将其作为DSL功能的一部分

  2. 在您的UI插件中,您将创建一个使用 IClasspathContainer 的实现Eclipse插件机制来检索JAR文件的位置

  3. 您创建一个 ClasspathContainerInitializer 的子类,创建一个您的 IClasspath容器实现

  4. 您创建一个小的 IClasspathContainerPage 向导页面,供用户使用Java Build添加库路径 - >项目设置中的库页面

  5. 您可以使用 org.eclipse.jdt.core.classpathContainerInitializer org.eclipse.jdt.ui.classpathContainerPage 扩展点

  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

在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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆