Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Separate model project
Separate model project [message #1732244] Fri, 13 May 2016 18:41 Go to next message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Dear all,

I would like to use the meta model generated by Xtext independently of Xtext. Therefore, I want to store the generated ecore and genmodel as well as the Java code related to the model in a separate plugin project.

I saw the modelPluginID property of the EMFGeneratorFragment2 class but I could not find documentation about this. After setting the property, I simply get an error from the PlatformResourceURIHandler that complains about an unmapped path:

java.io.IOException: The path '/mylanguage.model/model/generated/UML.ecore' is unmapped
	at org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl.createOutputStream(PlatformResourceURIHandlerImpl.java:501)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl.java:349)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:996)
	at org.eclipse.xtext.xtext.generator.ecore.EMFGeneratorFragment2.saveResource(EMFGeneratorFragment2.java:1107)
	at org.eclipse.xtext.xtext.generator.ecore.EMFGeneratorFragment2.generate(EMFGeneratorFragment2.java:498)
	at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)


Is it possible to use a separate model plugin without loosing the ability to infer the model from the Xtext grammar?

Best regards
Stephan
Re: Separate model project [message #1732262 is a reply to message #1732244] Sat, 14 May 2016 07:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
can you please open a ticket for that.

StandardProjectConfig does no allow you to add custom projects so far.



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Separate model project [message #1732263 is a reply to message #1732262] Sat, 14 May 2016 07:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
as a workaround you may try something like


package org.xtext.example.mydsl;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xtext.generator.model.project.BundleProjectConfig;
import org.eclipse.xtext.xtext.generator.model.project.StandardProjectConfig;
import org.eclipse.xtext.xtext.generator.model.project.SubProjectConfig;

import com.google.common.collect.Iterables;

public class ExtendedProjectConfig extends StandardProjectConfig {
	
	BundleProjectConfig c = new BundleProjectConfig();

	@Override
	public List<? extends SubProjectConfig> getAllProjects() {
		final ArrayList<SubProjectConfig> allProjects = CollectionLiterals.<SubProjectConfig> newArrayList();
		
		c.setEnabled(true);
		
		allProjects.add(c);
		Iterables.<SubProjectConfig> addAll(allProjects, super.getAllProjects());

		return allProjects;
	}
	
	@Override
	protected String computeName(SubProjectConfig project) {
		if (project == c) {
			return getBaseName()+".model";
		}
		return super.computeName(project);
	}

}



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Separate model project [message #1732416 is a reply to message #1732263] Tue, 17 May 2016 07:06 Go to previous messageGo to next message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Thanks for your fast reply. I managed to create the model and source code in another location but the base project still contains the generated meta models and the code. What I expected was a separate modeling project. This seems to be unsupported based on the source code in the EMFGeneratorFragment2.

I created a feature request: https://bugs.eclipse.org/bugs/show_bug.cgi?id=493768
Re: Separate model project [message #1733324 is a reply to message #1732416] Thu, 26 May 2016 13:23 Go to previous message
Stephan Seifermann is currently offline Stephan SeifermannFriend
Messages: 19
Registered: March 2015
Junior Member
Just to finish this topic: There is no easy way to separate the generated model from the runtime project. Therefore, I switched to the manually maintained model approach and use Xcore to create my meta model. The new bundle does not have any Xtext dependencies now, which enables reusing the meta model.

Nevertheless, I would like to see this feature in future Xtext releases because the manually maintained model introduces additional effort that does not provide any benefit (at least in my scenario).
Previous Topic:Web editing of DSLs
Next Topic:xtext.createEditor issue by using orion codeEdit plugin
Goto Forum:
  


Current Time: Sun Nov 17 04:41:38 GMT 2019

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

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

Back to the top