|
|
Re: how to restrict generation to a set of packages [message #552552 is a reply to message #552544] |
Thu, 12 August 2010 15:39 |
|
Here is a sample (built with xpand 1.0.0) but this should not matter.
Here a sample Model
<?xml version="1.0" encoding="UTF-8"?>
<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_0K2YkaYmEd-lhdqW6x_oOw">
<packagedElement xmi:type="uml:Package" xmi:id="_2KfVEKYmEd-lhdqW6x_oOw" name="a">
<packagedElement xmi:type="uml:Class" xmi:id="_6FnG0KYmEd-lhdqW6x_oOw" name="A"/>
</packagedElement>
<packagedElement xmi:type="uml:Package" xmi:id="_21fZ4KYmEd-lhdqW6x_oOw" name="b">
<packagedElement xmi:type="uml:Class" xmi:id="_6-vHMKYmEd-lhdqW6x_oOw" name="B"/>
</packagedElement>
</uml:Model>
and template
«DEFINE Root(String thename) FOR uml::Model»
«EXPAND PackageRoot FOREACH this.ownedElement.typeSelect(uml::Package).select(e|e.name == thename)»
«ENDDEFINE»
«DEFINE PackageRoot FOR uml::Package»
«EXPAND ClassRoot FOREACH this.ownedElement.typeSelect(uml::Class)»
«ENDDEFINE»
«DEFINE ClassRoot FOR uml::Class»
«FILE name + ".java"»
public class «name» {
}
«ENDFILE»
«ENDDEFINE»
and workflow
<workflow>
<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true"/>
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup">
<platformUri value=".." />
</bean>
<component class="org.eclipse.emf.mwe.utils.Reader">
<uri value="platform:/resource/my.generator.projectx/src/model/test.uml" />
<modelSlot value="model" />
</component>
<component class="org.eclipse.xpand2.Generator">
<metaModel class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel" />
<expand
value="template::Root::Root('b') FOR model" />
<outlet path="src-gen" >
<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
</outlet>
</component>
</workflow>
this sample filters for exacly one package and cannot handle package hierarchies (full qualified names) but this should be easyly adopable.
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
[Updated on: Thu, 12 August 2010 15:43] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03755 seconds