Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Running Xpand from Java can't find Xtend generator extension file
[Xpand] Running Xpand from Java can't find Xtend generator extension file [message #554135] Fri, 20 August 2010 09:29 Go to next message
Eclipse UserFriend
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 #554142 is a reply to message #554135] Fri, 20 August 2010 10:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13313
Registered: July 2009
Senior Member
Hi,

did you import the Xtend file within you Xpand template:

«EXTENSION path::to::GeneratorExtensions»


Regards
Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #554390 is a reply to message #554135] Sun, 22 August 2010 19:02 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
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

--
--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
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 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:[JET] taglib directive for "c" does not exist or TLD is not found.
Next Topic:[Acceleo 3] hasStereotype
Goto Forum:
  


Current Time: Tue Jan 21 22:44:16 GMT 2020

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

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

Back to the top