EditingGenericJetTemplates

Timothy Lethbridge edited this page Jun 14, 2016 · 4 revisions
Clone this wiki locally

THIS FILE IS OUT OF DATE FIXME

At one time when we used Jet, some of the Jet files were in common. Since we moved to UmpleTL none are. However, the common files were useful, so it might be good to move back in that direction.

Code generation is currently done using JET Templates. Code generation can be seen as querying the meta model to determine the types of code to generate (generic to all languages), and then to actually output the generated code (specific to all languages).

Any file that resembles the following is earmarked as a generic JET Template

<%@ jet package="cruise.umple.ignore" class="Ignore" %>
<%
{
  // GENERIC FILE - EDIT IN UmpleToTemplate project, then run "ant templates" to move into the appropriate projects
  for(Event e : uClass.getEvents())
  {
    %><%@ include file="state_machine_Event.jet" %><%
  }
}
%>

You should edit the UmpleToTemplate project as required.

Once ready, you can then promote that file to all projects using the Ant build script.

  cd /project/home
  cd ./build
  ant -Dmyenv=local -f build.codegen.xml

The results should look similar to

Buildfile: /Users/aforward/tp/projects/uottawa/umple/trunk/build/build.codegen.xml

build:

prepare:
     [copy] Copying 8 files to /Users/aforward/tp/projects/uottawa/umple/trunk/UmpleToJava/templates
     [copy] Copying 8 files to /Users/aforward/tp/projects/uottawa/umple/trunk/UmpleToPhp/templates
     [copy] Copying 8 files to /Users/aforward/tp/projects/uottawa/umple/trunk/UmpleToRuby/templates
     [copy] Copying 8 files to /Users/aforward/tp/projects/uottawa/umple/trunk/UmpleToCpp/templates

generate:

BUILD SUCCESSFUL
Total time: 0 seconds

CURRENTLY, JET TEMPLATES ARE COMPILED USING ECLIPSE, so you will still need the run the JET builder from within Eclipse. This should be updated to allow Ant to compile the Jet templates directly.

Note that there is also an ant target 'codegen'; this is for moving generated java code from the tamplates.