Generation with maven fornax plugin and use of own fragments [message #1403086] |
Mon, 21 July 2014 05:51  |
Eclipse User |
|
|
|
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>
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06590 seconds