Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to change the directory of the generated metamodel ?
How to change the directory of the generated metamodel ? [message #1806527] Fri, 10 May 2019 08:15 Go to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Hi

I would like to change the directory where the ecore metamodel is generated from model/generated to a custom directory.

How can I achieve that ?

Thanks for your help
Re: How to change the directory of the generated metamodel ? [message #1806528 is a reply to message #1806527] Fri, 10 May 2019 08:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
something like this should work

[code]
Workflow {

component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "org.xtext.example.mydsl1"
rootPath = rootPath
runtime = {
ecoreModel = "${rootPath}/org.xtext.example.mydsl1/model2/generated2/"
enabled = true
}
[code]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 10 May 2019 08:20]

Report message to a moderator

Re: How to change the directory of the generated metamodel ? [message #1806529 is a reply to message #1806528] Fri, 10 May 2019 08:31 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Thanks, is there a way to not overwrite the directory but only the ecore model ?
Re: How to change the directory of the generated metamodel ? [message #1806542 is a reply to message #1806529] Fri, 10 May 2019 09:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you be more specific about your usecase

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the directory of the generated metamodel ? [message #1806545 is a reply to message #1806542] Fri, 10 May 2019 10:07 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
The generated metamodel depends on another metamodel.
If I use this : ecoreModel = "${rootPath}/org.example.dsl/model/"

The second metamodel I specify in the Workflow using "referencedResource="platform:/resource/org.example.dsl/model/dsl2.genmodel" to be in the this directory. One generated it got overwrited.
Re: How to change the directory of the generated metamodel ? [message #1806547 is a reply to message #1806545] Fri, 10 May 2019 10:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
but why is that a problem. why to you specify referencedResource at all if you have two dsls in one workflow

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the directory of the generated metamodel ? [message #1806548 is a reply to message #1806547] Fri, 10 May 2019 10:38 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Because it removes dsl2.genmodel.

And if I want to execute the workflow again it can't find it.

[Updated on: Fri, 10 May 2019 10:40]

Report message to a moderator

Re: How to change the directory of the generated metamodel ? [message #1806550 is a reply to message #1806548] Fri, 10 May 2019 10:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
no i mean:
why having a referencedResource at all
(should not be needed, could be you trun into this problem: https://www.eclipse.org/forums/index.php/t/1098672/ - we did not receive a bug report yet)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the directory of the generated metamodel ? [message #1806553 is a reply to message #1806550] Fri, 10 May 2019 10:52 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Because I use this metamodel in my language via a cross reference.

Well, when I specify a different directory it works perfectly.

But I want to have both metamodels in the same directory. Because DSL1 metamodel uses a relative path to reference the metamodel of DSL2. And I want to be able to move and place them in the same directory.
Re: How to change the directory of the generated metamodel ? [message #1806559 is a reply to message #1806553] Fri, 10 May 2019 11:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i still cannot follow you what you are exactly doing.
you might have a look in the xtext code github.com/eclipse/xtext-core where the file is deleted


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the directory of the generated metamodel ? [message #1806561 is a reply to message #1806559] Fri, 10 May 2019 11:15 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Well, let me put it simply. Can I specify in the workflow to override only the dsl.ecore and dsl.genmodel, not overriding the whole directory as it does by default ?
Re: How to change the directory of the generated metamodel ? [message #1806567 is a reply to message #1806561] Fri, 10 May 2019 12:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
as i said: have a look at the code
(org.eclipse.xtext.xtext.generator.XtextDirectoryCleaner)
you can subclass that and bind a different impl
but i still dont understand

both ecore fill will be deleted.
if you checkin the code there should no model/generated be checked in
so the file wont be there



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 10 May 2019 12:25]

Report message to a moderator

Re: How to change the directory of the generated metamodel ? [message #1806609 is a reply to message #1806567] Sat, 11 May 2019 17:43 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Here my usecase, I added dsl2.genmodel into model/generated. And I reference it in the workflow.So, when I execute the workflow it will generate the ecore model and genmodel in model/generated.

I also put the dsl2.ecore because is used in my dsl1 Xtext syntax. Within the generated dsl1 ecore metamodel, each time a class from dsl2 is used, it specify where the dsl2 metamodel is located (something like that eType="ecore:EClass dsl1.ecore#//Port"). If dsl2.ecore is in the same directory then there will be no error, otherwise I have to put it in the directory.
Re: How to change the directory of the generated metamodel ? [message #1806616 is a reply to message #1806609] Sun, 12 May 2019 06:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
If dsl2.genmodel is written manually simply put it to model/notgenerated

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the directory of the generated metamodel ? [message #1806617 is a reply to message #1806616] Sun, 12 May 2019 07:07 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Yes I did that and it works, but I want it to be in the same directory than dsl1. Because I want them to be in the same directory, so that I can move them together.
Re: How to change the directory of the generated metamodel ? [message #1806619 is a reply to message #1806617] Sun, 12 May 2019 08:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
that said you need to use a custom generator and customize the place that i gave you.
but that said:
- its not easy
- there is no tutorial
here is a usecase for a different change
https://github.com/eclipse/xtext-web/blob/master/org.eclipse.xtext.web.example.entities/generator/org/eclipse/xtext/web/example/entities/EntitiesGeneratorModule.java
https://github.com/eclipse/xtext-web/blob/145546f2ba3b5ad26b6ecb5ab4f32ed420ba236d/org.eclipse.xtext.web.example.entities/src/org/eclipse/xtext/web/example/entities/GenerateEntities.mwe2#L19

if you use ci (maven/gradle) to build your dsl you may need a separate module to host
the customizations

=> really do this only if you are willing into digging into that yourself and consider its worth the time spent


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the directory of the generated metamodel ? [message #1806621 is a reply to message #1806619] Sun, 12 May 2019 08:48 Go to previous message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Ok, I will go with your recommandation.

Actually, that's not something that important, I just thought it was easy with some pre-defined agument in the Workflow.
Previous Topic:How scoping works on Ecore Editor ?
Next Topic:Combine Xtext editor with GEF editor
Goto Forum:
  


Current Time: Fri Apr 19 20:25:54 GMT 2024

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

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

Back to the top