Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using dynamic templates in Xcore(Problems with dynamic templates in xcore model lead to empty generated files)
Using dynamic templates in Xcore [message #1859783] Tue, 27 June 2023 08:56 Go to next message
Nis Wechselberg is currently offline Nis WechselbergFriend
Messages: 4
Registered: November 2022
Junior Member
Hi,

i am currently trying to adjust the code generation through dynamic templates in a model that is using Xcore with xtext-maven-plugin for the code generation.
I did the same thing in ecore/genmodel-projects before and that seems to be working fine.

However if I set dynamicTemplates to true in xcore, I only get empty files as generated code.

@GenModel(
    bundleManifest="false",
    modelDirectory="xcore-maven-example/src/main/java-gen",
    dynamicTemplates="true",
    templateDirectory="xcore-maven-example/src/resources/templates",
    complianceLevel="17"
)


I created a small example (thanks to Guillaume for the base project) at
https://github.com/eNBeWe/xcore-maven-example

Currently dynamicTemplates is false and it works fine. If I set it to true it immediately breaks.

Any ideas what is going on here?

[Updated on: Tue, 27 June 2023 10:23]

Report message to a moderator

Re: Using dynamic templates in Xcore [message #1859785 is a reply to message #1859783] Tue, 27 June 2023 09:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
There's nothing in the Error log? It's compiled into a hidden .JETEmiiters projects so you can disable the filtering of .* resources to see that project; maybe there are clues there.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Using dynamic templates in Xcore [message #1859787 is a reply to message #1859785] Tue, 27 June 2023 10:26 Go to previous messageGo to next message
Nis Wechselberg is currently offline Nis WechselbergFriend
Messages: 4
Registered: November 2022
Junior Member
I did not use it within Eclipse, but just through maven-plugin.
However your comment might point in the right direction nonetheless. I guess the process with the .JETEmiters project has a high chance of "confusing" the generation in maven, right?

I will try from within Eclipse and have a look there.

UPDATE:
I tested in Eclipse and it seems to work (after activating the plugin nature on the project, adding Manifest, etc.).
It generates the .JETEmitters project and uses the templates from there.

So it seems to be indeed a maven-plugin issue.
Any idea how to get that narrowed down?

[Updated on: Tue, 27 June 2023 10:39]

Report message to a moderator

Re: Using dynamic templates in Xcore [message #1859791 is a reply to message #1859787] Tue, 27 June 2023 11:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Unfortunately I have no clue how the stuff works in Maven. That's stuff done by the Xtext project. Certainly I think it will be a significant challenge to get this working in such a context. The current implementation relies on JDT compiling stuff in the .JETEmitters project and then loading the compiled classes dynamically. I.e., stuff in org.eclipse.emf.codegen.jet.JETEmitter.EclipseHelper.initialize(Monitor, JETEmitter) which will not trivially be made to work in a Maven build. But you're suggesting you got this working with a plain *.genmodel, but even for that case, I don't see how dynamic templates would have worked in a Maven build.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Using dynamic templates in Xcore [message #1859792 is a reply to message #1859791] Tue, 27 June 2023 11:50 Go to previous messageGo to next message
Nis Wechselberg is currently offline Nis WechselbergFriend
Messages: 4
Registered: November 2022
Junior Member
Okay, I kind of expected that now. I have been reading up on JET in the meantime and I don't see a simple approach to get that working.

For plain *.genmodel we don't use the maven-plugin but generate it in Eclipse and submit that code to git. So we didn't solve anything there ;)

I guess we have to think about some alternative. Either have the generated sources in git for xcore as well or have some other workaround ...

Thanks for your help nonetheless.

[Updated on: Tue, 27 June 2023 11:50]

Report message to a moderator

Re: Using dynamic templates in Xcore [message #1859796 is a reply to message #1859792] Tue, 27 June 2023 13:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
Committing the generated code to Git is a reasonable solution, but that's a religious issue. I even do that with generated Xtend used for the Xcore project itself.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:CDO Migrated to GitHub
Next Topic:[CDO] Efficiently moving a large containment structure
Goto Forum:
  


Current Time: Thu May 02 07:43:17 GMT 2024

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

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

Back to the top