Introduction

The "examples" directory contains scripts that show how to use the EMF Ant tasks available in this plugin. If you have any questions after reading and experimenting with them, look at the task's javadoc for more details.

The EMF java tasks are:

emf.JETEmitter Invokes the JETEmitter class to generate code from templates. org.eclipse.emf.ant/tasks/org/eclipse/emf/ant/taskdefs/codegen/JETEmitterTask.java
emf.JMerger Invokes the JMerger class to merge files. org.eclipse.emf.ant/tasks/org/eclipse/emf/ant/taskdefs/codegen/JMergerTask.java

Overall Comments

org.eclipse.emf.ant/examples/jet

Running JET from an Ant script sounds really convenient. And it is, especially when the templates you want to generate code from don't require complicated inputs - which are passed as the template's argument.

The Ant script available in this directory exercises 3 templates: "simple.javajet", "medium.javajet" and "complex.javajet". The first template is totally self-contained and doesn't use the argument variable. The second uses the argument variable but doesn't care about its state, so all we need to do is to specify its class and leave to the JETEmitter task the work of calling the Class.newInstance() method.

The last template, as stated by its name, is more complex. It will only produce a meaningful result if the specified argument is a list with at least one element - which is a good example of an object with state. The solution we've chosen to address this problem is to use the Script task. Please feel free to send us an email if you have a better solution ;-).

Since Script is an optional task, you will need to add the "bsd.jar" and the "js.jar" files to your classpath as mentioned in the Library Dependencies section of the Ant Manual. Because we are using Eclipse to run the script, the appropriate way of doing this is by adding these jar files as "extra classpath entries" using the org.eclipse.ant.core.extraClasspathEntries extension point - look at this plugin's manifest file to see how this extension is used.

org.eclipse.emf.ant/examples/jmerge

The Ant build script in this directory shows how to invoke the JMerger task.