Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to add a library directory to a project in my DSL
How to add a library directory to a project in my DSL [message #1048699] Wed, 24 April 2013 17:07 Go to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
I want to configure an Eclipse project with code in my DSL to recognize some library directories (which are external to the project folder). That is, I have some functions defined in these libraries which I want to call from my project.

The ideia is the same as including classes in the class path for Java or libraries for C. How can I do it?
Re: How to add a library directory to a project in my DSL [message #1048935 is a reply to message #1048699] Thu, 25 April 2013 02:11 Go to previous messageGo to next message
Wernke zur Borg is currently offline Wernke zur Borg
Messages: 9
Registered: December 2011
Junior Member
Hi Erick,

it depends on whether you have something like import statements in your DSL to include the code of the library headers or whether they are implicit. In any case the best way (to my experience) is a separate Xtext project with a separate grammar and model. Sebastian Zarnekow's article "Libraries Are Key" should give you a go. I am not allowed to post links here, so here is the link to copy: zarnekow.blogspot.de/2012/11/xtext-corner-8-libraries-are-key.html

Wernke

[Updated on: Thu, 25 April 2013 02:11]

Report message to a moderator

Re: How to add a library directory to a project in my DSL [message #1049169 is a reply to message #1048935] Thu, 25 April 2013 09:16 Go to previous messageGo to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
Wernke zur Borg wrote on Thu, 25 April 2013 02:11
Hi Erick,

it depends on whether you have something like import statements in your DSL to include the code of the library headers or whether they are implicit. In any case the best way (to my experience) is a separate Xtext project with a separate grammar and model. Sebastian Zarnekow's article "Libraries Are Key" should give you a go. I am not allowed to post links here, so here is the link to copy: zarnekow.blogspot.de/2012/11/xtext-corner-8-libraries-are-key.html

Wernke


The idea in the blog post is just what I want to do. I have the grammar for my DSL already defined, and want to create a file mylibs.mydsl in a common directory like /usr/lib. The problem is that I don't know how to make an Eclipse project with code written in my DSL to search /usr/lib/ or whatever directory.
Re: How to add a library directory to a project in my DSL [message #1052829 is a reply to message #1049169] Tue, 30 April 2013 11:45 Go to previous messageGo to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
So... anyone can help me? I will try to rephrase what I need.

I need to be able to use imports in my DSL files to include other files (or packages for that matter) that are NOT in the same project. Say I have myproject1 and myproject2, and both have files importing mylib.mydsl. Naturally, I don't want to have a copy of mylib.mydsl in both projects, but rather in a separate directory.

The problem is, as far as I know, import URI and import Namespace can only import stuff from the same project they are in. How can I get past this limitation?
Re: How to add a library directory to a project in my DSL [message #1052845 is a reply to message #1052829] Tue, 30 April 2013 12:50 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1308
Registered: July 2009
Senior Member
On 04/30/2013 05:45 PM, Erick Fonseca wrote:
> So... anyone can help me? I will try to rephrase what I need.
>
> I need to be able to use imports in my DSL files to include other files
> (or packages for that matter) that are NOT in the same project. Say I
> have myproject1 and myproject2, and both have files importing
> mylib.mydsl. Naturally, I don't want to have a copy of mylib.mydsl in
> both projects, but rather in a separate directory.
> The problem is, as far as I know, import URI and import Namespace can
> only import stuff from the same project they are in. How can I get past
> this limitation?

if you put your library DSL files in a bundle, the projects which depend
on that bundle will be able to refer to the library files :)

import namespace uses a classpath approach, thus it can import also
files contained in bundles a project depends on...

hope this helps
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Re: How to add a library directory to a project in my DSL [message #1052876 is a reply to message #1052845] Tue, 30 April 2013 17:42 Go to previous messageGo to next message
Erick Fonseca is currently offline Erick Fonseca
Messages: 63
Registered: December 2011
Member
Thank you for your answer. Ideally, I wanted a way to use a location for the library independent from Eclipse projects, but this will do.

I'm not sure if I know how to create a bundle, though. I created a simple Eclipse project and moved mylib.mydsl to it. There, I chose Configure->Convert to Plug-in Project. Is that it? And how can I set a dependency in the other projects?

Sorry for the silly questions, I'm not used to this Java style development.
Re: How to add a library directory to a project in my DSL [message #1053828 is a reply to message #1052876] Tue, 07 May 2013 14:49 Go to previous message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1308
Registered: July 2009
Senior Member
On 04/30/2013 11:42 PM, Erick Fonseca wrote:
> Thank you for your answer. Ideally, I wanted a way to use a location for
> the library independent from Eclipse projects, but this will do.
>
> I'm not sure if I know how to create a bundle, though. I created a
> simple Eclipse project and moved mylib.mydsl to it. There, I chose
> Configure->Convert to Plug-in Project. Is that it? And how can I set a
> dependency in the other projects?
> Sorry for the silly questions, I'm not used to this Java style development.

Yes, you can either convert it to Plug-in Project, or create a new
Plug-in Project; the packages you want to export must be declared in the
Runtime tab of the MANIFEST editor.

In other projects, you add a dependency to your library project in the
Dependencies tab of the MANIFEST editor.

Hope this helps
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Previous Topic:How can I infer jvm type which has super type which is derived from part of domain model
Next Topic:Cast of an IEObjectDescription object
Goto Forum:
  


Current Time: Sat Aug 02 02:32:58 EDT 2014

Powered by FUDForum. Page generated in 0.02418 seconds