public class JavaGeneratorTask extends GeneratorTask
Generates source code from models specified using Annotated Java. Exposes some
functionalities available on the JavaImporterApplication
class - check its printUsage() method for detailed information on the arguments
you can use with this task.
This task is supposed to be executed by a Eclipse driver with the org.eclipse.emf.ant plugin. It is neither necessary to use Ant's task TaskDef to declare this task in a script nor to change the Ant's runtime classpath.
The following command line will start a headless Eclipse instance and run the specified Ant script.
eclipseDir/eclipse -noSplash -data worspaceDir -application org.eclipse.ant.core.antRunner -buildfile antScript
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 this task by right-clicking the script and selecting Run As > Ant Build... > JRE > "Run in the same JRE as the workspace".
Usage example:
<emf.Java2Java genModel="/lib/emf/lib.genmodel">
<emf.Java2Java genModelPath="/lib/model/lib.genmodel" modelProject="c:/lib" <arg line="-packages http://www.example.eclipse.org/Library"/> </emf.Ecore2Java>
Different than the other EMF Generator tasks, this one requires the model specification files, Annotated Java, to be located in a workspace Java project. The genModelPath attribute should be used to indicated the workspace absolute path of the GenModel. Also, if the genModel's project doesn't exist in the workspace (indicated by workspaceDir in the command line above), the modelProject attribute should be used to indicate the model's location. This directory should contain all the Eclipse's necessary files (such as ".project" and ".classpath") to define this project as a valid Java project.
Also, the following attributes cannot be used within this task:
GeneratorTask.ModelLocation, GeneratorTask.ReconcileGenModelType
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
genModelPath |
protected JavaImporter |
javaImporter |
autoBuild, commandline, copyright, generateEditorProject, generateEditProject, generateJavaCode, generateModelProject, generateTestsProject, genModel, GENMODEL_KEEP, GENMODEL_OVERWRITE, GENMODEL_RELOAD, importOrganizing, jdkLevel, model, modelPluginID, modelProject, modelProjectFragmentPath, reconcileGenModel, sdo, templatePath, validateModel
Constructor and Description |
---|
JavaGeneratorTask() |
Modifier and Type | Method and Description |
---|---|
protected void |
addGenModelPathArgument() |
protected void |
checkAttributes()
All the attribute checks should be performed in this method.
|
protected void |
createGenModel(java.lang.String[] arguments) |
protected java.util.List<java.lang.String> |
getGeneratorArguments() |
void |
setGenModel(java.io.File genModel) |
void |
setGenModelPath(java.lang.String genModelPath) |
void |
setModel(java.io.File model) |
void |
setModelProjectFragmentPath(java.lang.String modelProjectFragmentPath) |
addGenModelArguments, addModelPathArgument, adjustEditAndEditorProjects, createArg, createModel, doExecute, generateCodeFromGenModel, getCommandline, getJDKLevel, setAutoBuild, setCopyright, setGenerateEditorProject, setGenerateEditProject, setGenerateJavaCode, setGenerateModelProject, setGenerateTestsProject, setImportOrganzing, setJdkLevel, setModelPluginID, setModelProject, setReconcileGenModel, setReconcileGenModel, setSDO, setTemplatePath, setValidateModel, supportMultipleURIs
assertTrue, execute, getProgressMonitor
protected java.lang.String genModelPath
protected JavaImporter javaImporter
public void setModel(java.io.File model)
setModel
in class GeneratorTask
public void setGenModel(java.io.File genModel)
setGenModel
in class GeneratorTask
public void setModelProjectFragmentPath(java.lang.String modelProjectFragmentPath)
setModelProjectFragmentPath
in class GeneratorTask
public void setGenModelPath(java.lang.String genModelPath)
protected void createGenModel(java.lang.String[] arguments) throws java.lang.Exception
createGenModel
in class GeneratorTask
java.lang.Exception
protected void checkAttributes() throws BuildException
EMFTask
checkAttributes
in class GeneratorTask
BuildException
protected void addGenModelPathArgument()
addGenModelPathArgument
in class GeneratorTask
protected java.util.List<java.lang.String> getGeneratorArguments()
getGeneratorArguments
in class GeneratorTask