[Xpand] Running Xpand from Java can't find Xtend generator extension file [message #554135] |
Fri, 20 August 2010 09:29 |
Eclipse User |
|
|
|
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl
Hi all,
running my Xpand template with MWE is no problem:
<?xml version="1.0"?>
<workflow>
<property name="metamodel"
value="metamodels/cif/nl.tue.cif.v2x1x1.metamodel/model/cif.ecore"/>
<property name="model"
value="m2t/cif_cifascii/nl.tue.cif.v2x1x1.cifascii.v2x1x1/test_models/example.cifx"/>
<property name="outputdir" value="test_models"/>
<!-- set up EMF for standalone execution -->
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup">
<platformUri value="../../.."/>
<RegisterEcoreFile value="platform:/resource/${metamodel}"/>
</bean>
<!-- instantiate metamodel -->
<bean id="mm_emf"
class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
<!-- load model and store it in slot 'model' -->
<component class="org.eclipse.emf.mwe.utils.Reader">
<uri value="platform:/resource/${model}"/>
<modelSlot value="model"/>
</component>
<!-- generate code -->
<component class="org.eclipse.xpand2.Generator">
<metaModel idRef="mm_emf"/>
<expand value="template::Template::expSpecification FOR model"/>
<outlet name='OUT_FILE' path="${outputdir}/example.cif"/>
</component>
</workflow>
This works fine. However, I'm trying to run the template from Java code
in a different project, without using the MWE file at all. I'm trying to
use the XpandFacade class. I have this code:
(...)
String templateName = "expSpecification"
String outputFolder = "xpandOutput";
List<Object> params = new ArrayList<Object>();
EObject targetObject = inResource.getContents().get(0);
OutputImpl output = new OutputImpl();
Outlet outlet = new Outlet(outputFolder);
outlet.setOverwrite(true);
output.addOutlet(outlet);
Outlet outputOutlet = new Outlet("testOutput");
outputOutlet.setName("OUT_FILE");
output.addOutlet(outputOutlet);
XpandExecutionContextImpl executionContext = new
XpandExecutionContextImpl(output, null);
executionContext.registerMetaModel(new EmfRegistryMetaModel());
org.eclipse.xtend.expression.Resource template =
executionContext.getResourceManager().loadResource("/mnt/(...anonymized...)/nl.tue.cif.v2x1x1.cifascii.v2x1x1/src/template/Template",
"xpt");
executionContext =
(XpandExecutionContextImpl)(executionContext.cloneWithResource(template));
XpandFacade facade = XpandFacade.create(executionContext);
facade.evaluate2(templateName, targetObject, params);
This does indeed locate the metamodels, and the Xpand template. However,
upon execution I get:
EvaluationException : Couldn't find operation 'urgentToString(Boolean)'
for cif::Model.
::mnt::(...anonymized..)::nl.tue.cif.v2x1x1.cifascii.v2x1x1::src::template::Template.xpt[2395,27]
on line 56 'urgentToString(this.urgent)'
::mnt::(...anonymized..)::nl.tue.cif.v2x1x1.cifascii.v2x1x1::src::template::Template.xpt[285,65]
on line 11 'EXPAND expTopLevelDeclaration FOREACH declarations SEPARATOR
'\n''
at
org.eclipse.internal.xtend.expression.ast.OperationCall.evaluateInternal(OperationCall.java:155)
at
org.eclipse.internal.xtend.expression.ast.Expression.evaluate(Expression.java:50)
at
org.eclipse.internal.xpand2.ast.ExpressionStatement.evaluateInternal(ExpressionStatement.java:45)
at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
at
org.eclipse.internal.xpand2.ast.AbstractDefinition.evaluate(AbstractDefinition.java:180)
at
org.eclipse.internal.xpand2.ast.ExpandStatement.invokeDefinition(ExpandStatement.java:246)
at
org.eclipse.internal.xpand2.ast.ExpandStatement.evaluateInternal(ExpandStatement.java:191)
at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
at
org.eclipse.internal.xpand2.ast.FileStatement.evaluateInternal(FileStatement.java:86)
at org.eclipse.internal.xpand2.ast.Statement.evaluate(Statement.java:41)
at
org.eclipse.internal.xpand2.ast.AbstractDefinition.evaluate(AbstractDefinition.java:180)
at org.eclipse.xpand2.XpandFacade.evaluate2(XpandFacade.java:62)
at
(...)
The urgentToString is located in GeneratorExtensions.ext, in the same
directory as the Template.xpt file, but Xpand can't find it. How do I
tell Xpand where to find the Xtend file?
Thanks,
Dennis
|
|
|
|
Re: [Xpand] Running Xpand from Java can't find Xtend generator extension file [message #554180 is a reply to message #554142] |
Fri, 20 August 2010 12:34 |
Eclipse User |
|
|
|
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl
Hi Christian,
> did you import the Xtend file within you Xpand template:
Yes, I have this in my Xpand template:
«EXTENSION template::GeneratorExtensions»
Best,
Dennis
Christian Dietrich wrote:
> Hi,
>
> did you import the Xtend file within you Xpand template:
>
>
> «EXTENSION path::to::GeneratorExtensions»
>
>
> Regards
> Christian
|
|
|
|
Re: [Xpand] Running Xpand from Java can't find Xtend generator extension file [message #554684 is a reply to message #554390] |
Tue, 24 August 2010 05:59 |
Eclipse User |
|
|
|
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl
> Make sure the template as well as the extension file is on your
> process' classpath
That did the trick!
Thanks,
Dennis
Sven Efftinge wrote:
> Am 8/20/10 11:29 AM, schrieb Dennis Hendriks:
>
>> The urgentToString is located in GeneratorExtensions.ext, in the same
>> directory as the Template.xpt file, but Xpand can't find it. How do I
>> tell Xpand where to find the Xtend file?
>
> Make sure the template as well as the extension file is on your process'
> classpath and reove the following two lines (the resource manager will
> load the files from classpath) :
>
> org.eclipse.xtend.expression.Resource template =
> executionContext.getResourceManager().loadResource(" /mnt/(...anonymized...)/nl.tue.cif.v2x1x1.cifascii.v2x1x1/sr c/template/Template ",
>> "xpt");
>> executionContext =
>> (XpandExecutionContextImpl)(executionContext.cloneWithResour ce(template));
>
> Sven
>
|
|
|
Powered by
FUDForum. Page generated in 0.24592 seconds