org.eclipse.emf.importer.ecore Read Me

### Introduction

This document describes how you can use scripts to generate code from an Ecore model. The script can be either a regular shell script that invokes Eclipse headless applications or an Ant script that invokes the task provided by this plugin.

### Overall Comments

- If you didn't extract this plugin from CVS, the "examples" directory mentioned in this document is available in the EMF source plugin (org.eclipse.emf.source_<version>/src/org.eclipse.emf.importer.ecore_<version>).
- Before running your build scripts or the examples provided here, make sure you have the 2 jar files required by this plugin ("importer.ecore.jar" and "importer.ecore.tasks.jar") and also the 2 jar files required by the `org.eclipse.emf.ant` plugin ("emf.ant.jar" and "emf.ant.tasks.jar"). If necessary, Eclipse can generate them for you. All you need to do is to run the Ant script created by PDE when you right click on the manifest file and select "PDE Tools>Create Ant Build File".
- Although the applications and task mentioned here must be executed by Eclipse (usually in headless mode), they can work on files located in any directory. In other words, your models, templates and other files don't need to be in the "plugins" directory nor in the workspace.
- In order to preserve the original state of this plugin's "examples" directory, you should copy it to a different location and run the Ant scripts from there.
- Starting a new JVM process and invoking Eclipse are expensive operations. Your build will perform better if you are able to group the steps that require Eclipse in a few scripts (one script would be ideal). This is probably a reason to use Ant instead of invoking the applications - you can generate code for multiple models using one single Ant script.
- The "examples/library" directory contains an Ecore model, and shell and Ant scripts to generate its code.

### Ecore and Generator Applications

The application provided by this plugin generates the ecore and genmodel files from models defined using EMF.

Ecore application details
ID | `org.eclipse.emf.importer.ecore.Ecore2GenModel`
Class | `org.eclipse.emf.importer.ecore.EcoreImporterApplication`

To generate the actual Java code you will need to use a second application, provided by the "org.eclipse.emf.codegen.ecore" plugin.

Generator application details
ID | `org.eclipse.emf.codegen.ecore.Generator`
Class | `org.eclipse.emf.codegen.ecore.Generator`

In order to run these or any other Eclipse application, you need to execute the following command (without the line breaks):

eclipse
-noSplash
-data <full path to a workspace - ideally an empty directory>
-application <application ID>
<application arguments>

In Windows you should execute eclipsec instead of eclipse in order to have access to the application's console output.

The directory "examples/library/build" has shell scripts that generate the code for the model provided. If you have any questions after reading and experimenting with it, look at the applications's javadoc for more details. Also, check the application's class "getUsage()" method for the list of possible arguments.

### Ecore Ant Task

The Ecore task details are:

Name | `emf.Ecore2Java`
Class | `org.eclipse.emf.importer.ecore.taskdefs.EcoreGeneratorTask`

This is the usual command line to run an Ant script using a headless Eclipse instance (remove the line breaks):

eclipse
-noSplash
-data <full path to a workspace - ideally an empty directory>
-application org.eclipse.ant.core.antRunner
-buildfile <full path to your script>

In Windows you should execute eclipsec instead of eclipse in order to have access to the Ant build script console output.

You can also use the Eclipse UI to execute an Ant script containing an EMF task. This can be done by right-clicking the script and selecting Run As > Ant Build... > JRE > "Run in the same JRE as the workspace".

The directory "examples/library/build" has an Ant script that generate the code for the model provided. The task's javadoc has lots of information you may find useful.