Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Programmatically duplicating the effects of Generate Model Code(What are the Java classes called when I generate model code from a genmodel file?)
Programmatically duplicating the effects of Generate Model Code [message #1803115] Fri, 22 February 2019 16:01 Go to next message
Alex Thompson is currently offline Alex ThompsonFriend
Messages: 1
Registered: February 2019
Junior Member
I am working on a module to automate a semi-manual process which currently includes the use of EMF to generate a large number of Java files based on a genmodel file (A sample.genmodel which is similar to the actual file is below. I have broken up the hyperlinks in the root XML tag).

Currently, in our manual process, we have to open the sample.genmodel file, right-click the root genPackage (named Zxyw), and click Generate Model Code. All of the necessary Java classes are then generated inside the folder

I would like to figure out the Java code necessary to achieve the same effect as clicking Generate Model Code. As mentioned above, this code generation is only part of a larger process, which is being automated though a Java program.

Thank you for your help and guidance on this.


<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmlns:ecore="http: //" xmlns:xmi="http: //" codeFormatting="true" complianceLevel="7.0" copyrightFields="false" dynamicTemplates="true" featureDelegation="Dynamic" importOrganizing="true" importerID="org.eclipse.emf.importer.ecore" modelDirectory="/somedirectory/src-gen/main/java" modelName="Zxyw" modelPluginID="modelPluginID" operationReflection="true" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" xmi:version="2.0" xmlns:genmodel="http: //">
<genPackages basePackage="example.basepackage" disposableProviderFactory="true" ecorePackage="sample.ecore#/" prefix="Zxyw">
<nestedGenPackages basePackage="example.basepackage.sample" disposableProviderFactory="true" ecorePackage="sample.ecore#//enums" prefix="Enums">
<!-- several genEnums tags -->
<nestedGenPackages basePackage="example.basepackage.sample" disposableProviderFactory="true" ecorePackage="sample.ecore#//events" prefix="Events">
<!-- several genClasses tags -->
<nestedGenPackages basePackage="example.basepackage.sample" disposableProviderFactory="true" ecorePackage="sample.ecore#//models" prefix="Models">
<!-- several genClasses tags -->
<nestedGenPackages basePackage="example.basepackage.sample" disposableProviderFactory="true" ecorePackage="sample.ecore#//eventresults" prefix="Eventresults">
<!-- several genClasses tags -->
<genPackages prefix="Models" basePackage="example.basepackage" disposableProviderFactory="true"
loadInitialization="true" literalsInterface="false" ecorePackage="models.ecore#/">
<!-- several genEnums, genDatattypes, and genClasses tags -->
Re: Programmatically duplicating the effects of Generate Model Code [message #1803135 is a reply to message #1803115] Sat, 23 February 2019 06:14 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6585
Registered: July 2009
Senior Member

In Java, you can use EMF's Generator API.

Historically this kind of control was performed using Ant for which EMF provides Ant tasks. These are little used, painful to maintain and might fade away.

Much better to use MWE2, for which I developed the bean a few years ago. There is now org.eclipse.emf.mwe.utils.GenModelHelper, but I have never used it.


Ed Willink
Previous Topic:[CDO] Reset Password [ERROR] No credentials update provider configured
Next Topic:Reference Model A classes in Model B without regenerating Model A
Goto Forum:

Current Time: Thu Feb 20 15:33:30 GMT 2020

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

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

Back to the top