Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generation with maven fornax plugin and use of own fragments(Problem, when using own fragment in mwe2 file and doing a maven build)
Generation with maven fornax plugin and use of own fragments [message #1403086] Mon, 21 July 2014 09:51 Go to next message
Adrian Pollak is currently offline Adrian PollakFriend
Messages: 27
Registered: August 2013
Junior Member
Hello,

I have a problem with the maven based Xtext generation using the fornax plugin and an self implemented fragment.

I developed a naming fragment (TypeModelQualifiedNamesFragment.java) and reference it in the mwe2 file (GenerateTypeModel.mwe2).

Unfortunately, I get and exception that the fragment cannot be found. It looks like it is not in the classpath.
XtextLinkingDiagnostic: null:86 Couldn't resolve reference to JvmType 'com.my.dsl.naming.TypeModelQualifiedNamesFragment'.

My question is how to extend the classpath by the missing fragment or how to setup the fragment properly?

When I deactivate the fragement, everything is build properly but of course the IDE functionality is missing in eclipse.
The goal is that the maven fornax build should also be able to include the own written fragment.

Any help is appreciated.

Regards

Adrian


GenerateTypeModel.mwe2
module com.my.dsl.GenerateTypeModel

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

var grammarURI = "classpath:/com/my/dsl/TypeModel.xtext"
var fileExtensions = "bam,def"
var projectName = "com.my.dsl"
var runtimeProject = "../${projectName}"
var generateXtendStub = true

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 = DirectoryCleaner {
    	directory = "${runtimeProject}.tests/src-gen"
    }
    
    component = Generator {
    	pathRtProject = runtimeProject
    	pathUiProject = "${runtimeProject}.ui"
    	pathTestProject = "${runtimeProject}.tests"
    	projectNameRt = projectName
    	projectNameUi = "${projectName}.ui"
//    	srcPath = "/target/classes"
    	language = auto-inject {
    		uri = grammarURI
    
    		// Java API to access grammar elements (required by several other fragments)
    		fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    
    		// generates Java API for the generated EPackages
    		fragment = ecore.EcoreGeneratorFragment auto-inject {
    		// referencedGenModels = "
    		//  platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
    		//  platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
    		// "
    		}
    
    		// the old serialization component
    		// fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}    
    
    		// serializer 2.0
    		fragment = serializer.SerializerFragment auto-inject {
    			generateStub = false
    		}
    
    		// a custom ResourceFactory for use with EMF
    		fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
    
    		// The antlr parser generator fragment.
    		fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
    		//  options = {
    		//      backtrack = true
    		//  }
    		}
    
    		// Xtend-based API for validation
    		fragment = validation.ValidatorFragment auto-inject {
    		//    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
    		//    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
    		}
    
    		// old scoping and exporting API
    		// fragment = scoping.ImportURIScopingFragment auto-inject {}
    		// fragment = exporting.SimpleNamesFragment auto-inject {}
    
    		// scoping and exporting API
    		fragment = scoping.ImportNamespacesScopingFragment auto-inject {}

//    		fragment = exporting.QualifiedNamesFragment auto-inject {}

// !!! THE FOLLOWING FRAGMENT LEADS TO A BUILD ERROR
    		fragment = naming.TypeModelQualifiedNamesFragment auto-inject {}

    		fragment = builder.BuilderIntegrationFragment auto-inject {}
    
    		// generator API
    		fragment = generator.GeneratorFragment auto-inject {}
    
    		// formatter API
    		fragment = formatting.FormatterFragment auto-inject {}
    
    		// labeling API
    		fragment = labeling.LabelProviderFragment auto-inject {}
    
    		// outline API
    		fragment = outline.OutlineTreeProviderFragment auto-inject {}
    		fragment = outline.QuickOutlineFragment auto-inject {}
    
    		// quickfix API
    		fragment = quickfix.QuickfixProviderFragment auto-inject {}
    
    		// content assist API
    		fragment = contentAssist.ContentAssistFragment auto-inject {}
    
    		// generates a more lightweight Antlr parser and lexer tailored for content assist
    		fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
    
    		// generates junit test support classes into Generator#pathTestProject
    		fragment = junit.Junit4Fragment auto-inject {}
    
    		// project wizard (optional)
    		// fragment = projectWizard.SimpleProjectWizardFragment auto-inject {
    		//      generatorProjectName = "${projectName}"
    		// }
    
    		// rename refactoring
    		fragment = refactoring.RefactorElementNameFragment auto-inject {}
    
    		// provides the necessary bindings for java types integration
    		fragment = types.TypesGeneratorFragment auto-inject {}
    
    		// generates the required bindings only if the grammar inherits from Xbase
    		fragment = xbase.XbaseGeneratorFragment auto-inject {}
    
    		// provides a preference page for template proposals
    		fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
    
    		// provides a compare view
    		fragment = compare.CompareFragment auto-inject {}
    	}
    }
}



fragment file
package com.my.dsl.naming;

import java.util.Set;

import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.generator.BindFactory;
import org.eclipse.xtext.generator.Binding;
import org.eclipse.xtext.generator.exporting.QualifiedNamesFragment;
import org.eclipse.xtext.naming.IQualifiedNameProvider;

// extension of Sebastian Zarnekow's fragment
public class TypeModelQualifiedNamesFragment extends QualifiedNamesFragment {
	@Override
	public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
		return new BindFactory().addTypeToType(IQualifiedNameProvider.class.getName(),
				TypeModelQualifiedNameProvider.class.getName()).getBindings();
	}
}



exception
[INFO] --- tycho-packaging-plugin:0.19.0:validate-version (default-validate-version) @ com.my.dsl ---
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) @ com.my.dsl ---
[INFO] Source directory: C:\workspaces\head\com.my.dsl\src-gen added.
[INFO] Source directory: C:\workspaces\head\com.my.dsl\src added.
[INFO] Source directory: C:\workspaces\head\com.my.dsl\xtend-gen added.
[INFO]
[INFO] --- fornax-oaw-m2-plugin:3.4.0:run-workflow (default) @ com.my.dsl ---
[INFO] Fornax Model Workflow Maven2 Plugin V3.4.0
[INFO] src\com\portigon\f4ja\ba\dsl\GenerateTypeModel.mwe2 has been modified since last generator run at 20140718-14:43:10.
[INFO] Executing workflow in forked mode.
[ERROR] 1    [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - [XtextLinkingDiagnostic: null:86 Couldn't resolve reference 
          to JvmType 'com.my.dsl.naming.TypeModelQualifiedNamesFragment'.]
[INFO] java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:86 Couldn't resolve reference to 
          JvmType 'com.my.dsl.naming.TypeModelQualifiedNamesFragment'.]
[ERROR]         at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:88)
[ERROR]         at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
[ERROR]         at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
[ERROR]         at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
[ERROR]         at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
[ERROR] ExitStatusException occurred while running workflow: Java returned: 1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] BA DSL/BAM Generator Module ....................... SUCCESS [0.153s]
[INFO] BA DSL Module ..................................... FAILURE [3.641s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.635s
[INFO] Finished at: Fri Jul 18 16:14:45 CEST 2014
[INFO] Final Memory: 73M/357M
[INFO] ------------------------------------------------------------------------



pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<relativePath>../com.my.generator/pom.xml</relativePath>
		<groupId>com.my</groupId>
		<artifactId>com.my.generator</artifactId>
		<version>1.0.0</version>
	</parent>
	
	<artifactId>com.my.dsl</artifactId>
	<name>BA DSL Module</name>
	<packaging>eclipse-plugin</packaging>

	<build>
		<sourceDirectory>src</sourceDirectory>

		<resources>
			<resource>
				<directory>src</directory>
				<includes>
					<include>**/*.xtext</include>
				</includes>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<version>${maven-clean-plugin.version}</version>
				<configuration>
					<filesets>
						<fileset>
							<directory>src-gen</directory>
							<includes>
								<include>**</include>
							</includes>
						</fileset>
						<fileset>
							<directory>src/main</directory>
							<includes>
								<include>**/**</include>
							</includes>
						</fileset>
						<fileset>
							<directory>xtend-gen</directory>
							<includes>
								<include>**/**</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.8</version>
				<executions>
					<execution>
						<id>add-source</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>src-gen</source>
								<source>src</source>
								<source>xtend-gen</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.fornax.toolsupport</groupId>
				<artifactId>fornax-oaw-m2-plugin</artifactId>
				<version>3.4.0</version>
				<configuration>
					<workflowEngine>mwe2</workflowEngine>
					<workflowDescriptor>src/com/my/dsl/GenerateTypeModel.mwe2</workflowDescriptor>
				</configuration>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>run-workflow</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.eclipse.xtend</groupId>
				<artifactId>xtend-maven-plugin</artifactId>
				<version>${xtext-maven-plugin.version}</version>
				<configuration>
					<encoding>Cp1252</encoding>
				</configuration>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>compile</goal>
						</goals>
						<configuration>
							<outputDirectory>xtend-gen</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
		
	</build>
	
</project>
Re: Generation with maven fornax plugin and use of own fragments [message #1403110 is a reply to message #1403086] Mon, 21 July 2014 12:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

the the custom fragment in a separate maven module?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generation with maven fornax plugin and use of own fragments [message #1403114 is a reply to message #1403110] Mon, 21 July 2014 12:40 Go to previous messageGo to next message
Adrian Pollak is currently offline Adrian PollakFriend
Messages: 27
Registered: August 2013
Junior Member
Hi Christian,

yes the TypeModelQualifiedNamesFragment.java fragment is within the "com.my.dsl"-project where also the mwe2-file belongs to.

Do I have to manifest the fragment in a special kind?
Re: Generation with maven fornax plugin and use of own fragments [message #1403115 is a reply to message #1403114] Mon, 21 July 2014 12:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
it has to be a SEPARATE!!! maven module.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generation with maven fornax plugin and use of own fragments [message #1403120 is a reply to message #1403115] Mon, 21 July 2014 13:07 Go to previous messageGo to next message
Adrian Pollak is currently offline Adrian PollakFriend
Messages: 27
Registered: August 2013
Junior Member
I will do a separation in a new maven project that will then only consist of this fragment.

But why does the eclipse generation get along with the fragment in the same project?

Re: Generation with maven fornax plugin and use of own fragments [message #1403123 is a reply to message #1403120] Mon, 21 July 2014 13:50 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
cause elipse already compiled the fragment at the point when the workflow is called.
it does not care about phases.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:3 DSLs, references inbetween and eProxies
Next Topic:Recognizing identical parts
Goto Forum:
  


Current Time: Fri Mar 29 15:15:15 GMT 2024

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

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

Back to the top