Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » fornax-oaw-m2-plugin extended generator
fornax-oaw-m2-plugin extended generator [message #1017429] Mon, 11 March 2013 20:16 Go to next message
Artem G. is currently offline Artem G.
Messages: 10
Registered: October 2012
Junior Member
Hi folks,

I'm using fornax-oaw-m2-plugin to build my Xtext-DSL plugin with maven. There is a component in MWE2 workflow, which is my implementation of an extended generator for my DSL.

module org.example.GenerateTestDSL

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/example/TestDSL.xtext"
var file.extensions = "testdsl"
var projectName = "org.example.testdsl"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
            scanClassPath = true
            
            platformUri = "${runtimeProject}/.."
            // The following two lines can be removed, if Xbase is not used.
            registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
            registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
        }
    
        component = DirectoryCleaner {
            directory = "${runtimeProject}/src-gen"
        }
    
        component = DirectoryCleaner {
            directory = "${runtimeProject}.ui/src-gen"
        }
    
        component = org.example.ExtendedGenerator {
        	srcPath = "/src/main/java"
        	srcGenPath = "/src/generated/java"
        	
           ...
            
        }
    }
}


If I build the project using fornax-oaw-m2-plugin to run MWE2 workflow it is unable to resolve my extended generator class, if I place this extended generator class in the same package with MWE2 workflow and it is in classpath. If I start MWE2 workflow alone from eclipse -- all works fine. The problem is I think, fornax-oaw-m2-plugin needs compiled classes in generate-sources phase, but they get compiled in compile phase, which is after it.

I found a dirty solution: if I create new project, place extended generator class in it and add it as a dependency by fornax-oax-m2-plugin like this:

<plugin>
				<groupId>org.fornax.toolsupport</groupId>
				<artifactId>fornax-oaw-m2-plugin</artifactId>
				<dependencies>
					<dependency>
						<groupId>org.example</groupId>
						<artifactId>org.example.testdsl.postprocessor</artifactId>
						<version>${project.version}</version>
					</dependency>
				</dependencies>
				<configuration>
					<workflowDescriptor>src/main/resources/org/example/GenerateTestDSL.mwe2</workflowDescriptor>
				</configuration>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>run-workflow</goal>
						</goals>
					</execution>
				</executions>
			</plugin>


I'm able to build it with maven, but I'm getting an error in Eclipse in MWE2 workflow file. It can't resolve the extended generator class. But sure, while it is in another project. I have tried to add this project as a dependency in the DSL pom.xml but MWE2 is unable to resolve it. It seams to me that MWE2 workflow use only MANIFEST.MF to resource dependencies. So what should I do to solve this issue: able to build MWE2 workflow with custom component with maven and no errors in eclipse. While extracting extended generator in separate project only to be able to build it with maven is a really dirty solution.

Thanks for help,
Artem.
Re: fornax-oaw-m2-plugin extended generator [message #1017431 is a reply to message #1017429] Mon, 11 March 2013 20:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6292
Registered: July 2009
Senior Member
Hi,

do you use tycho if yes what about adding it to a common.lib osgi bundle and use that as a dep in the manifest?
Re: fornax-oaw-m2-plugin extended generator [message #1017439 is a reply to message #1017431] Mon, 11 March 2013 20:44 Go to previous messageGo to next message
Artem G. is currently offline Artem G.
Messages: 10
Registered: October 2012
Junior Member
Hi Christian,

thanks for your reply. You have a wonderful blog about Xtext. Smile

Do you mean I did a right thing with extracting ExtendedGenerator.java in a separate project and use it as a dependency? If I understand you properly, I should require bundle of a generator project in the DSL project? Sorry but I don't understand, what do you mean with common.lib and I found nothing in google. Can you give me please a little bit more context, I'am no so strong in OSGi?

Thanks and greeting from Germany Smile
Re: fornax-oaw-m2-plugin extended generator [message #1017445 is a reply to message #1017439] Mon, 11 March 2013 21:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6292
Registered: July 2009
Senior Member
Hi,

yes you create a module yourdsl.common.lib or whatever you want to call it and use it a dependency from the xtext project.
Re: fornax-oaw-m2-plugin extended generator [message #1017447 is a reply to message #1017445] Mon, 11 March 2013 21:05 Go to previous message
Artem G. is currently offline Artem G.
Messages: 10
Registered: October 2012
Junior Member
I tried this way, but got some issue by installing a plugin after build. I didn't tried to solve it just gave up, while I thought it is not a right way. So thanks, I'm going to mark this thread as solved.
Previous Topic:dependency injection in Xtext source code
Next Topic:Validating Manually
Goto Forum:
  


Current Time: Tue Sep 16 13:37:50 GMT 2014

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

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