Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » using a model form another project
using a model form another project [message #659333] Sat, 12 March 2011 12:28 Go to next message
Martin Trummer is currently offline Martin TrummerFriend
Messages: 15
Registered: February 2011
Junior Member
What is a good way to tell the reader to use a model that is stored in antoher eclipse project?

When I set "useJavaClassPath = true", the generation works, but the clipse console is completely messed up and throws a lot of errors: I guess, that the classpath that is printed is just too long.

Anyway - is it possible to use smth. like "path = 'classpath:/model/"?
Re: using a model form another project [message #659433 is a reply to message #659333] Sun, 13 March 2011 21:37 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Is your question about referring to a model to import in the Xtext
grammar? If so, you can look at how it is done in the
cloudsmith/geppetto project at github - project
/org.cloudsmith.geppetto.pp.dsl.generate (which contains the mwe
workflow). It uses Xtext 2.0 so some parts of the mwe are not applicable
to 1.0 (but the references to external/imported models work the same way).

Regards
- henrik

On 3/12/11 1:28 PM, Martin Trummer wrote:
> What is a good way to tell the reader to use a model that is stored in
> antoher eclipse project?
>
> When I set "useJavaClassPath = true", the generation works, but the
> clipse console is completely messed up and throws a lot of errors: I
> guess, that the classpath that is printed is just too long.
>
> Anyway - is it possible to use smth. like "path = 'classpath:/model/"?
>
Re: using a model form another project [message #659466 is a reply to message #659333] Mon, 14 March 2011 07:38 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

note that "path" in the component is an adder, that is you can use it multiple times to add folders that should be searched. In order to add folders in other projects, a quick and dirty way is to add the full path of that folder in the workflow

path=modelPath
path="/Users/user/workspace/projectName/src/modelfolder"

Also, you should be a bit more adventurous in using the Eclipse navigation features. You could have used F3 to get from "path" in the workflow to the corresponding adder in the Reader component. If you investigate the uses of the paths, you would see that the PathTraverser used by the component simply creates a new File from the path and checks them for directories and archives. So unless the File class can deal with classpath uris, the answer to your last question is obviously "No".

Feel free to implement your own Reader component that resolves these uris.

Alex
Re: using a model form another project [message #659491 is a reply to message #659466] Mon, 14 March 2011 09:33 Go to previous messageGo to next message
Martin Trummer is currently offline Martin TrummerFriend
Messages: 15
Registered: February 2011
Junior Member
Hi,

thanks for the answers so far, but I see that my question was not clear enough:

I have these xtext projects:

  • dsl
  • dsl.generator
  • dsl.ui


then I have 2 application projects with models, say:

  • common:
    /src/main/xtext/model/common.dsl

  • server:
    /src/main/xtext/model/server.dsl


the server.dsl imports common.dsl

In the server project I also have a workflow and I need to tell the reader in this workflow to read all *.dsl files in any model diretories, i.e. the server.dsl file in the server project and the common.dsl file that will be available in the jar file of the common project.

I guess this is a very common project setup.

When I simply set useJavaClassPath=true of the Reader, it works - but as already mentioned causes severe eclipse problems - so I cannot use it.
Maybe if there's a way to suppress the output of the classpath to the console, it would be a workaround - But I don't know how to configure this.

@Alexander
I was browsing the source code and it was quite clear to me, that the Reader does not work. I also noticed that there's an UriBasedReader, but since I'm a newbie I have no idea how to use it and I cannot find any examples: thus, I hoped that someone could easily answer the question (e.g. use the UriBasedReader with "uri = "classpath://common.jar!model/*.dls")
Re: using a model form another project [message #659606 is a reply to message #659491] Mon, 14 March 2011 19:26 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

maybe I still don't understand your problem well enough, as the "messed up" console has never been a problem for me before.

Have you tried adding a Uri-Filter to the reader component when using the classpath option set to true?
Something along the following lines

useJavaClassPath = true
uriFilter=org.eclipse.xtext.mwe.NameBasedFilter{
extension="dsl"
}

Alex
Re: using a model form another project [message #659674 is a reply to message #659606] Tue, 15 March 2011 08:31 Go to previous message
Martin Trummer is currently offline Martin TrummerFriend
Messages: 15
Registered: February 2011
Junior Member
Hi,

I agree - "messed up" is really not very meaningful Smile

what actually happens, is that the console shows crap and that there are a lot of errormessages in the eclipse Error Log. All subsequent tools that want to use the console don't work after that happens - thus I must restart eclipse (which takes quite long).
this is for sure an eclipse problem (not TMF related) - but it seems that this will not be fixed:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=87299

I've tried the UriFilter with extenstion - but this won't work - when you look at the implementation of invokeInternal() it will only use the filter against the classpath which does not contain the *.dsl files, but only *.jar files.

Anyway: I think I will change my project setup to have all the models and generators in one project and set the outlets to the relative projects (e.g. "../common/src/..."). It's not that clean, but it will also have the benefit, that I don't need any TMF related dependencies in the application-projects (avoiding classloading issues).
Previous Topic:Integrate Xtext with CDO DbStore
Next Topic:minor bug with var in Generator.exapand
Goto Forum:
  


Current Time: Fri Apr 26 11:20:56 GMT 2024

Powered by FUDForum. Page generated in 0.03086 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top