Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customizing ecore model
Customizing ecore model [message #1739957] Sat, 06 August 2016 00:20 Go to next message
Johannes Tempel is currently offline Johannes TempelFriend
Messages: 3
Registered: January 2015
Junior Member
Hello,

I'm trying to migrate my old Xtext project to Xtext 2.10
I customize/refine my model like this: http://www.lorenzobettini.it/2014/02/switching-from-an-inferred-ecore-model-to-an-imported-one-in-your-xtext-grammar/

The Problem is, this does not work with the new XtextGenerator (org.eclipse.xtext.xtext.generator.XtextGenerator) in the MWE2 Workflow

My Steps to create a new project:
- used the Wizard to create an Xtext project from existing Ecore model
- moved the model directory (containing the .ecore and .genmodel files) into the new projekt,
- in MyDSL.xtext : changed
 "generate myDsl http://www.xtext.org/example/mydsl/MyDsl"
to
import "http://www.xtext.org/example/mydsl/MyDsl"

- in GenerateMyDsl.mwe2: changed
 referencedResource = "platform:/resource/my.old.project/model/custom/MyDsl.genmodel"
to
 referencedResource = "platform:/resource/org.xtext.example.mydsl/model/custom/MyDsl.genmodel"


There are no warnings or errors, but the XtextGenerator does not generate the Java code for the grammar, the directory src-gen/org/example/mydsl/MyDsl/ is empty.
Xtext is referencing to the generated files from the old project.

How can I tell Xtext to generate everything from the grammar? Is something missing in the workflow?
Thanks,
Johannes


Here is the full Workflow:
module org.xtext.example.mydsl.GenerateMyDsl

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {
	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "org.xtext.example.mydsl"
				rootPath = rootPath
				eclipsePlugin = {
					enabled = true
				}
				createEclipseMetaData = true
			}
			code = {
				encoding = "windows-1252"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
		language = StandardLanguage {
			name = "org.xtext.example.mydsl.MyDsl"
			fileExtensions = "mydsl"
			referencedResource = "platform:/resource/org.xtext.example.mydsl/model/custom/MyDsl.genmodel"
			
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

			fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
				fragment = org.eclipse.xtext.generator.ecore2xtext.FormatterFragment {}
			}

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
		}
	}
}
Re: Customizing ecore model [message #1739959 is a reply to message #1739957] Sat, 06 August 2016 04:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14104
Registered: July 2009
Senior Member
What is the error you get

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Customizing ecore model [message #1739960 is a reply to message #1739959] Sat, 06 August 2016 05:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14104
Registered: July 2009
Senior Member
p.s.

are you sure you

- added xtext.generator to the deps
- added ecoregenerator/setup stuff to the workflow
- do the directory cleaning right?


Workflow {
	
	bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
        scanClassPath = true
        platformUri = rootPath
    }
	
	component = org.eclipse.emf.mwe2.ecore.EcoreGenerator {
        genModel = "platform:/resource/org.xtext.example.mydsl4/model/custom/MyDsl.genmodel"
        srcPath = "platform:/resource/org.xtext.example.mydsl4/src"
        
    }
....
// todo add cleaner
....
	component = XtextGenerator {
// disable default cleaner
		cleaner = {
			enabled = false
		}


p.s. i'd prefer to move the stuff to a completely separate plugin/project or at least or move the emf stuff to a separate source folder (in genmodel)

<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
    xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="generated by Xtext 2.10.0" modelDirectory="/org.xtext.example.mydsl4/emf-gen"
....
    


Workflow {
	
	bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
        scanClassPath = true
        platformUri = rootPath
    }
    
    component = org.eclipse.emf.mwe.utils.DirectoryCleaner {
    	directory = "emf-gen"
    }
	
	component = org.eclipse.emf.mwe2.ecore.EcoreGenerator {
        genModel = "platform:/resource/org.xtext.example.mydsl4/model/custom/MyDsl.genmodel"
        srcPath = "platform:/resource/org.xtext.example.mydsl4/src"
        
    }
    
    
	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "org.xtext.example.mydsl4"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				}
				eclipsePlugin = {
					enabled = true
				}
				eclipsePluginTest = {
					enabled = true
				}
				createEclipseMetaData = true
			}
			code = {
				encoding = "UTF-8"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
		language = StandardLanguage {
			name = "org.xtext.example.mydsl4.MyDsl"
			fileExtensions = "mydsl4"
			
			referencedResource = "platform:/resource/org.xtext.example.mydsl4/model/custom/MyDsl.genmodel"
			
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

			fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
				fragment = org.eclipse.xtext.generator.ecore2xtext.FormatterFragment {}
			}

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
		}
	}
}



<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="src-gen"/>
	<classpathentry kind="src" path="emf-gen"/>
	<classpathentry kind="src" path="xtend-gen"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
	<classpathentry kind="output" path="bin"/>
</classpath>



source.. = src/,\
           src-gen/,\
           xtend-gen/,\
           emf-gen/
bin.includes = model/generated/,\
               .,\
               META-INF/,\
               plugin.xml
additional.bundles = org.eclipse.xtext.xbase,\
                     org.eclipse.xtext.common.types,\
                     org.eclipse.xtext.xtext.generator,\
                     org.eclipse.emf.codegen.ecore,\
                     org.eclipse.emf.mwe.utils,\
                     org.eclipse.emf.mwe2.launch,\
                     org.eclipse.emf.mwe2.lib,\
                     org.objectweb.asm,\
                     org.apache.commons.logging,\
                     org.apache.log4j,\
                     com.ibm.icu,\
                     org.eclipse.xtext.generator,\
                     org.eclipse.xtext.ecore



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Customizing ecore model [message #1740070 is a reply to message #1739960] Mon, 08 August 2016 22:08 Go to previous message
Johannes Tempel is currently offline Johannes TempelFriend
Messages: 3
Registered: January 2015
Junior Member
I added the ecoregenerator and setup to my workflow and moved the generated files to emf-gen as you've suggested. Now it works fine, thank you Smile
Previous Topic:Loading Xtext based model from Eclipse EASE
Next Topic:index is incomplete during auto build after cleaning more than one project
Goto Forum:
  


Current Time: Tue Dec 07 04:25:32 GMT 2021

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

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

Back to the top