Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XCore Generation Workflow
XCore Generation Workflow [message #1077109] Thu, 01 August 2013 08:59 Go to next message
Igor Zapletnev is currently offline Igor ZapletnevFriend
Messages: 33
Registered: September 2012
Member
I am trying to execute xcore generation workflow (as start point I am using this bug)

My root application for xcore generation. It just uses Mwe2Runner

public class GenXcoreApplication implements IApplication {

	private String model;
	private String output;

	@Override
	public Object start(IApplicationContext context) throws Exception {
		Injector injector = new Mwe2StandaloneSetup()
				.createInjectorAndDoEMFRegistration();
		Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
		runner.run(URI.createPlatformPluginURI(
				"com.home.genxcore/src/xcoregen.mwe2", true),
				new HashMap<String, String>());
		return null;
	}


It is workflow to execute

module com.home.genxcore.Xcoregen

Workflow {
	component = org.eclipse.emf.mwe.utils.DirectoryCleaner {
		directory = "model-gen"
	}
	
	component = com.home.genxcore.XcoreReader {
		register = org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup {}
		path = "/Users/zapletnev/Documents/src/xcoregen/xtest/model"
		slot = "model"
	}

	component = org.eclipse.xtext.generator.GeneratorComponent {
		register = org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup {}
		slot = 'model'
		outlet = {
			path = "/Users/zapletnev/Documents/src/xcoregen/xtest/src-gen"
		}
	}
}


And newly created XCoreReader (it parses xcore files and sets them as a slots)

package com.home.genxcore;
// some imports here...

public class XcoreReader extends AbstractWorkflowComponent2 {

	protected List<String> pathes = Lists.newArrayList();

	public void addPath(String path) {
		this.pathes.add(path);
	}

	public List<String> getPathes() {
		return pathes;
	}

	private String slot;

	public String getSlot() {
		return slot;
	}

	public void setSlot(String slot) {
		this.slot = slot;
	}

	@Override
	protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
			Issues issues) {
		ResourceSet resourceSet = getResourceSet();
		Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes,
				new Predicate<URI>() {
					@Override
					public boolean apply(URI input) {
						return input.fileExtension().equals("xcore");
					}
				});
		List<Resource> resources = new ArrayList<Resource>();
		for (URI uri : uris.values()) {
			String path = uri.toFileString();
			Resource r;
			System.out.println(path);
			try {
				r = parse(new FileInputStream(path), uri, null, resourceSet);
				resources.add(r);
			} catch (FileNotFoundException e) {
				issues.addError("problem beim lesen", e);
				e.printStackTrace();
			}
		}
		EcoreUtil.resolveAll(resourceSet);
		for (Resource r : resources) {
			for (Diagnostic x : r.getErrors()) {
				issues.addError(x.getMessage(), x);
			}

		}
		ctx.set(slot, resources);

	}

	private Resource parse(InputStream in, URI uriToUse, Map<?, ?> options,
			ResourceSet resourceSet) {

		XtextResource resource = (XtextResource) resourceSet
				.createResource(uriToUse);
		resourceSet.getResources().add(resource);
		try {
			resource.load(in, options);
			return resource;
		} catch (IOException e) {
			throw new WrappedException(e);
		}
	}

	protected PathTraverser getPathTraverser() {
		return new PathTraverser();
	}

	protected ResourceSet getResourceSet() {
		if (!injectors.isEmpty()) {
			ResourceSet instance = injectors.get(0).getInstance(
					ResourceSet.class);
			return instance;
		}
		return new ResourceSetImpl();
	}

	private final List<Injector> injectors = Lists.newArrayList();

	public void addRegister(ISetup setup) {
		injectors.add(setup.createInjectorAndDoEMFRegistration());
	}

	protected List<Injector> getInjectors() {
		return injectors;
	}

}



Manifest file of my applicatin plug-in
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.home.genxcore;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.emf.ecore;visibility:=reexport,
 org.eclipse.ui,
 org.eclipse.emf.mwe2.runtime,
 org.eclipse.emf.mwe.utils;bundle-version="1.2.1",
 org.eclipse.emf.mwe2.lib;bundle-version="2.3.0",
 org.eclipse.emf.mwe.core;bundle-version="1.2.1",
 org.eclipse.xtext;bundle-version="2.3.1",
 org.eclipse.emf.ecore.xcore;bundle-version="1.0.2",
 org.eclipse.emf.mwe2.launch;bundle-version="2.3.0",
 org.eclipse.xtext.xbase;bundle-version="2.3.1",
 org.eclipse.xtext.xbase.lib;bundle-version="2.3.1",
 org.eclipse.emf.ecore.xcore.lib;visibility:=reexport,
 com.google.guava,
 org.eclipse.xtext.ecore;bundle-version="2.3.1"
Bundle-ActivationPolicy: lazy


And the main issue it is that I am getting following errors:
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:8 Couldn't resolve reference to JvmType 'com.home.genxcore.XcoreReader'., XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmIdentifiableElement 'register'., XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmType 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'., XtextLinkingDiagnostic: null:10 Couldn't resolve reference to JvmIdentifiableElement 'path'., XtextLinkingDiagnostic: null:11 Couldn't resolve reference to JvmIdentifiableElement 'slot'., XtextLinkingDiagnostic: null:15 Couldn't resolve reference to JvmType 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'.]


Can anyone explain that I have missed?
Re: XCore Generation Workflow [message #1077116 is a reply to message #1077109] Thu, 01 August 2013 09:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Looks like the classpath is insufficient

--
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: XCore Generation Workflow [message #1077119 is a reply to message #1077109] Thu, 01 August 2013 09:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
BTW calling stand alone set ups from eclipse is a bad idea

--
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: XCore Generation Workflow [message #1077137 is a reply to message #1077119] Thu, 01 August 2013 09:37 Go to previous messageGo to next message
Igor Zapletnev is currently offline Igor ZapletnevFriend
Messages: 33
Registered: September 2012
Member
I don't have any other way. I am trying to setup maven build to generate xcore. I am using typcho-eclipserun plug-in for this.
Re: XCore Generation Workflow [message #1077138 is a reply to message #1077137] Thu, 01 August 2013 09:40 Go to previous messageGo to next message
Igor Zapletnev is currently offline Igor ZapletnevFriend
Messages: 33
Registered: September 2012
Member
Looks like I have found the main issue
Class.forName(classNameUtil.normalizeClassName(name), false, classLoader)

throws ClassNotFoundException with name=com.home.genxcore.XcoreReader
java.lang.ClassNotFoundException: com.home.genxcore.XcoreReader cannot be found by org.eclipse.emf.mwe2.language_2.4.0.v201306110940


How I can solve this issue?
Re: XCore Generation Workflow [message #1077169 is a reply to message #1077137] Thu, 01 August 2013 10:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Have a look at the fornax maven workflow plugin

--
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: XCore Generation Workflow [message #1077170 is a reply to message #1077137] Thu, 01 August 2013 10:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
And make sure you build the reader class in another module so that it
is binary in classpath

--
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: XCore Generation Workflow [message #1077194 is a reply to message #1077170] Thu, 01 August 2013 11:00 Go to previous messageGo to next message
Igor Zapletnev is currently offline Igor ZapletnevFriend
Messages: 33
Registered: September 2012
Member
I have moved XCoreResource to the separated plug-in, but still getting this error.
Could you please explain how it should works?
org.eclipse.emf.mwe2.language really could not resolve qualifier name "XCoreReader", it has no dependencies to it. Or it should be resolved from specified IScopeProvider?
Re: XCore Generation Workflow [message #1077215 is a reply to message #1077194] Thu, 01 August 2013 11:36 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

it works if the class is on the classpath. i dont know anything about your machanism so i cannot say how to fix the classpath.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Context menu on running product not visible
Next Topic:Using maven to test an Xtext DSL to Java generator
Goto Forum:
  


Current Time: Thu Sep 19 02:48:08 GMT 2024

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

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

Back to the top