Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Compile stand-alone Java application containing JET-Templates outside of eclipse GUI(How to compile with eclipse version >2020 JET-Templates in a shell script or ant-build,...)
Compile stand-alone Java application containing JET-Templates outside of eclipse GUI [message #1851386] Mon, 04 April 2022 14:52 Go to next message
Jens Goldeck is currently offline Jens GoldeckFriend
Messages: 3
Registered: April 2022
Junior Member
Hi,

we have a stand alone Java-application, which offers a big set of generators for design artefacts. Input of this application are certain type of XML files.

So we used JET-Templates for a lot of this generators and up to now we compile our tool inside of Eclipse manually and then check-in the jar-file in order to deploy it. This worked now already for some 10years.
Now we are trying for some time to automize that compile and deployment, using git, jenkings,... and also try to offer some nightly builds for different branches, so that people can test new features before release.

Question is: How can we compile the JET-Files outside of eclipse in a jenkins job, using a makefile, ant-file, ... ?

I did not find any HowTos (in this forum, EMF help pages, tutorials) which are newer than from 2009. Could you help me out here?

Currently we have a VERY slow script, calling eclipse in batch mode for every single file, all other ant-scripts or tutorials seem not to work with current eclipse versions.

First a loop for each jet file with:
eclipse-jee-neon-2-linux-gtk-x86_64/eclipse/eclipse -data <path> -application org.eclipse.emf.codegen.CodeGen <jetFile> <projectPath>/src

And after that something like this:
java -Dant.home=<path>/apache-ant-1.10.7 -cp apache-ant-1.10.7/lib/ant-launcher.jar org.apache.tools.ant.launch.Launcher -buildfile <path>/build.xml

This loop takes more than 10minutes because eclipse is called for each file.
Re: Compile stand-alone Java application containing JET-Templates outside of eclipse GUI [message #1851390 is a reply to message #1851386] Mon, 04 April 2022 18:31 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7548
Registered: July 2009
Senior Member
Hi

When Eclipse does something good 'automatically' and you want to re-use that functionality, you can either read a lot of code or search for missing documentation or ....

Start a nested Eclipse under debug, setting a breakpoint wheresome aspect of something good happens, then examine the stack trace of how you got there and emulate it in your own code.

For a modeling activity, in the absence of better inspiration, the creation of a relevant Resource can be a plausible starting point.

In your case you know that there is an automated Eclipse build driven by a JET nature so search for the JET builder/nature and set breakpoints there.

Regards

Ed Willink
Re: Compile stand-alone Java application containing JET-Templates outside of eclipse GUI [message #1851402 is a reply to message #1851390] Tue, 05 April 2022 06:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32563
Registered: July 2009
Senior Member
Jens, for my own use of JET templates, I simply check in the generated Java files rather than try to generate them in my Maven/Tycho build. Little effort has been invested in how to invoke the org.eclipse.emf.codegen.jet.JETCompiler, though there are org.eclipse.emf.ant.taskdefs.codegen.JETCompilerTask, org.eclipse.emf.ant.taskdefs.codegen.JETEmitterTask and org.eclipse.emf.codegen.CodeGen. I suppose that latter could be made more efficient if it could handle a list of templates rather than just one. Maybe one of the ant tasks is a better fit.

You could build your own solution looking that what's there in EMF:

https://ci.eclipse.org/emf/

(Or sponsor someone to do it.)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Compile stand-alone Java application containing JET-Templates outside of eclipse GUI [message #1851432 is a reply to message #1851402] Tue, 05 April 2022 14:37 Go to previous messageGo to next message
Jens Goldeck is currently offline Jens GoldeckFriend
Messages: 3
Registered: April 2022
Junior Member
THanks for the quick reply.

We had once the "check-in of java files" solution but saw a lot of false "merge events". But maybe nowerdays with our git solution that might be okay.

I will maybe also try again the ant-task. Some years ago I failed in brining the eclipse ant-runner to life from outside.

Yes, improving the EMF API would be beneficial, my company also contributes a lot to eclipse is part of it, but I guess, EMF is not in the focus. Maybe I find someone. I myself have no external budget to give and digging into EMF myself would be a big working package.
Re: Compile stand-alone Java application containing JET-Templates outside of eclipse GUI [message #1851433 is a reply to message #1851390] Tue, 05 April 2022 14:39 Go to previous message
Jens Goldeck is currently offline Jens GoldeckFriend
Messages: 3
Registered: April 2022
Junior Member
Starting eclipse in debug mode is an interesting approach. But still I would need to make the "found code" also available from outside in batch.mode. That would still be a big effort, which would not go into my appliaction, but only the compiler... Maybe I will try that out one day.
Previous Topic:validation display in TreeMasterDetailSWTRenderer
Next Topic:Deriving a property value from another derived property using OCL
Goto Forum:
  


Current Time: Thu Dec 01 16:53:19 GMT 2022

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

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

Back to the top