Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to avoid code generation of the refered ecore file in genmodel file(cross reference)
How to avoid code generation of the refered ecore file in genmodel file [message #1830264] Wed, 22 July 2020 12:03 Go to next message
David Sun is currently offline David SunFriend
Messages: 45
Registered: July 2020
Member

I created A.ecore and B.ecore files in seperated emf projects(A project for A.ecore, B project for B.ecore).

For A.ecore, I created A.genmodel and generated java code from it and added it into the "dependencies" of B project.

I open B.ecore in Ecore Model Editor and Loaded(by "Load Resource..." popup menu) A.ecore file into the same Ecore Model Editor.

In B.ecore, I created EClass YYY and created a EReference for it, refered a Eclass XXX of A.ecore.

Then I created B.genmodel for B.ecore.

I open B.genmodel in EMF Generator Editor and there were B.ecore and A.ecore.

I did not need generating code from A.ecore in B project, So I deleted A.ecore.

Then I choosed "Generate All" from popup menu for B.ecore.

There was the problem, in MANIFEST.MF, it exported packages of A.ecore in "Runtime" Tab, But there was no package of A.ecore in the B project and the eclipse show me errors.

I want to kown how to avoid B project export packages of A.ecore after generating code from B.ecore ?
Thanks a lot!
Re: How to avoid code generation of the refered ecore file in genmodel file [message #1830276 is a reply to message #1830264] Wed, 22 July 2020 14:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
When you create/reload the B.genmodel you should use the dialog 's "Package Selection" page to choose A's GenPackage in the "Referenced generator models" section. I'm not sure what you meant by deleting A.ecore; it's GenPackage in A.genmodel definitely needed by B.genmodel...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to avoid code generation of the refered ecore file in genmodel file [message #1830299 is a reply to message #1830276] Thu, 23 July 2020 03:38 Go to previous messageGo to next message
David Sun is currently offline David SunFriend
Messages: 45
Registered: July 2020
Member
In Ecore Model Editor of ladder.ecore , I loaded PLCVariables.ecore.
index.php/fa/38629/0/
index.php/fa/38630/0/
Then I created an EClass xxx for ladder.ecore, and created an EReference for xxx and refered an EClass yyy of PLCVariables.ecore.

I open ladder.gemodel in EMF Generator Editor. The plcvariables was shown under Ladder.
index.php/fa/38631/0/

On "Model" node in EMF Generator Editor of ladder.genmodel, I selected "Generate All" from popup menu.
index.php/fa/38632/0/

After genreating the code, The eclipse show me errors.
index.php/fa/38634/0/

The EMF added packages of plcvariables.ecore into "Runtime" . But there was no package of plcvariables.ecore in ladder.model's project.

My question is : How can I avoid those errors? I generated code of plcvariables.ecore in plcvariables.ecore's project, I added those generated packages of plcvaraibles.ecore into "dependencies" of ladder.ecore's project.How can I disable emf add pakcages of refered plcvariables.ecore automatically? I do not need those packages in ladder.ecore's project.
index.php/fa/38634/0/

  • Attachment: 1.png
    (Size: 19.15KB, Downloaded 391 times)
  • Attachment: 2.png
    (Size: 13.74KB, Downloaded 379 times)
  • Attachment: 3.png
    (Size: 7.81KB, Downloaded 375 times)
  • Attachment: 4.png
    (Size: 25.29KB, Downloaded 376 times)
  • Attachment: 7.png
    (Size: 85.70KB, Downloaded 400 times)
Re: How to avoid code generation of the refered ecore file in genmodel file [message #1830302 is a reply to message #1830299] Thu, 23 July 2020 06:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
In your 3.png I can see that Ladder.genmodel has two GenPackages, Model and Plcvariables. That means this GenModel will generate and expects to generate all the code and infrastructure for two GenPackages. But that's not what you want because you already have a project where you've generated all the code/infrastructure for Plcvariables. So this Ladder.genmodel should contain only one genPackage element like this one:

https://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore.change/model/Change.genmodel#n12

But yours contains two of them. Instead the Pclvariables GenPackage should be referenced as a usedGenPackage like this:

https://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore.change/model/Change.genmodel#n7

To achieve that you should Reload.. the GenModel either from the Generator menubar or from the context menu of the *.genmodel resource and make sure the final page looks like this:

index.php/fa/38635/0/


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to avoid code generation of the refered ecore file in genmodel file [message #1830307 is a reply to message #1830302] Thu, 23 July 2020 07:05 Go to previous message
David Sun is currently offline David SunFriend
Messages: 45
Registered: July 2020
Member
Thank you for your advice.
It solved my problem!
Cool !
Previous Topic:Please delete this post
Next Topic:[Compare] Using ExtensionPoint for PostProcessor
Goto Forum:
  


Current Time: Tue Apr 16 04:47:32 GMT 2024

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

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

Back to the top