Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext replace "scr-gen" directory(Xtext, how to replace the default output directory programmatically)
icon5.gif  xtext replace "scr-gen" directory [message #1067183] Sun, 07 July 2013 10:13 Go to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
I use xtext to generate code (XML-Schema), My problem is, that the framework uses the "src-gen" as output by default. I would like to change the outputfolder according to a given path by user in DSL programmatically. The output folder could be any where, in the same project which contains the DSL, or any other Eclipse project.
For detail description see the following example:
Assume I have 2 Eclipse projects A and B. Projekt A contains the DSL-file, where the user specifies the path for the output directory. When the user edits and saves the DSL file, I would like to get the path to the output folder programmatically and replace the default output folder "src-gen".
Now I have 4 questions:

1. What is the easiest way to define the path to the new outputdirectory in the grammar?
2. How do I access the path defined by user?
3. How can I replace the default output directory "src-gen" (programmatically)?
4. Should I do the step asked in question 3 once or twice if I want to solve the problem in the runtime instance of Eclipse and for a deployed plugin?

I am sorry, if I ask to much, I tried a lot and could not solve my problem.
I appreciate your help. Please give, if possible detailed information and code example
Thanks in advance
Re: xtext replace "scr-gen" directory [message #1067197 is a reply to message #1067183] Sun, 07 July 2013 13:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i am not quite sure what this question is targeting.
in the default setup
you can open a projects (the one the .mydsl file is contained) properties. then go to "MyDsl -> Compiler" there you can specify besides other stuff the output dir.
the code magic on this is in org.eclipse.xtext.generator.IOutputConfigurationProvider (org.eclipse.xtext.builder.EclipseOutputConfigurationProvider in running eclipse)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067283 is a reply to message #1067197] Mon, 08 July 2013 08:09 Go to previous messageGo to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
Hi Christian,
thank you for reply.
I'm afraid my question ist not clear enough. You are right with changing the output default setup by compile property. That is what I know too. My problem is, that the changed oupt put will be still within the same project like the ".mydsl" file. I would like to give the user the possibility to choos arbitrarily location (path) for the output, within any project, not only in the project contained the ".mydsl". I hope, I am clear now.
My idea is to let the user specifi the path to the output directory in the ".mydsl".
I looked at org.eclipse.xtext.generator.IOutputConfigurationProvider and org.eclipse.xtext.builder.EclipseOutputConfigurationProvider, but I am not sure, how can I solve my problem. Please give me some code examples.
Than you.
Re: xtext replace "scr-gen" directory [message #1067286 is a reply to message #1067283] Mon, 08 July 2013 08:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi the projects properties are stored in the project. For anything
further you have to digg yourself

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067305 is a reply to message #1067286] Mon, 08 July 2013 09:19 Go to previous messageGo to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
Yes,it should be independent form project properties. I wanted to do it by my slef, but how should I do it? There I need help.
Re: xtext replace "scr-gen" directory [message #1067308 is a reply to message #1067305] Mon, 08 July 2013 09:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sorry I don't have the time to do this for you as I said you have to
customize ioutputconfigurationprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067315 is a reply to message #1067308] Mon, 08 July 2013 09:48 Go to previous messageGo to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
Sorry, that was never my aim to let you do it for me.
Could you give just a hint, how do I start to customize ioutputconfigurationprovider?
Re: xtext replace "scr-gen" directory [message #1067320 is a reply to message #1067315] Mon, 08 July 2013 09:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Since I don't know your wanted behaviour I can only point you to look
a existing inplemenations what I did

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067323 is a reply to message #1067320] Mon, 08 July 2013 10:03 Go to previous messageGo to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
Do you mean, my wanted ist still unclear for you? if yes, caused by my "poor" English?
Re: xtext replace "scr-gen" directory [message #1067342 is a reply to message #1067323] Mon, 08 July 2013 11:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi I don't know how the user interface for this should
Look like. You have already a project based config for this I don't
know how your solution differs from this

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067350 is a reply to message #1067342] Mon, 08 July 2013 11:47 Go to previous messageGo to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
Ok, I see, I'm still not clear, so I try it with an example.

Assume that is my gramma

grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
    greetings+=Greeting*;
    Greeting:
    'Hello' name=ID '!';


The java file will be created in the "src-ge" (default setting) folder.

But I want, that the java file should to create in the folder, which comes form DSL, so
I change my gramma to.

grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
    greetings+=Greeting*;
    Greeting:
    'Hello' name=ID '!';
    outputdirectory=Outputdirectory;

Outputdirectory: 'ouput' name=ID 


Now in DSL the user has to specifi the outputdirectory and the java file should created there.
My problem:

How shloud I say to generator progammatically, take the user outputdirectory form DSL instead of "src-gen" for generating.

Re: xtext replace "scr-gen" directory [message #1067362 is a reply to message #1067350] Mon, 08 July 2013 12:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi did you simply try to specify a relative path to the
FSA.generatefile

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067368 is a reply to message #1067362] Mon, 08 July 2013 12:47 Go to previous messageGo to next message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
Hi,
do you mean in the complie proerty page of the project? If yes, yes I did it like this.

Project-A:
Project-B:

Project A contains DSL

I put in comiple page of project-A the relative specifikation like this
../../Project-B/src-genNew

reuslt: no generating

[Updated on: Mon, 08 July 2013 12:57]

Report message to a moderator

Re: xtext replace "scr-gen" directory [message #1067370 is a reply to message #1067368] Mon, 08 July 2013 12:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sorry was just a hint. I fear you have to debug into the magic
yourself

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext replace "scr-gen" directory [message #1067380 is a reply to message #1067370] Mon, 08 July 2013 13:19 Go to previous message
Eathen Saw is currently offline Eathen SawFriend
Messages: 11
Registered: July 2013
Junior Member
I have already wrote my own OutputConfigurationProvider, implements the
IOutputConfigurationProvider, binded it and got mutiple output. But that is not a dynamically solution. It still works just with the complie property.
I fear debuggig would not help me, or I am not sure, what do you mean with debugging.
Previous Topic:NamesAreUniqueValidator & JvmModelInferrer
Next Topic:Bi Directional Cross-Document Referance on XTEXT
Goto Forum:
  


Current Time: Thu Mar 28 16:38:22 GMT 2024

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

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

Back to the top