This project implements a simple Process Definition Language (PDL) using Model-Driven Engineering (MDE) techniques with the Eclipse Modeling Framework (EMF). It uses Ecore for metamodeling and Acceleo for code generation from SimplePDL models.
GitHub Repository: github.com/tomdieu/simplePDL
- Eclipse Modeling Framework (EMF)
- Ecore: For defining the SimplePDL metamodel (
model/simplePDL.ecore).
- Ecore: For defining the SimplePDL metamodel (
- Acceleo: For defining model-to-text transformations (code generation) (
src/simplePDL/main/generate.mtl). - Java: For the Acceleo generator launcher (
src/simplePDL/main/Generate.java). - Ant: For automating the generation process (
tasks/). - XMI: For persisting model instances (
instances/).
model/: Contains the SimplePDL metamodel (simplePDL.ecore) and related files.src/: Contains the Acceleo generation templates (generate.mtl) and the Java launcher (Generate.java).instances/: Contains example model instances conforming to the SimplePDL metamodel (e.g.,MakingCoffe.xmi,WritingAReport.xmi).tasks/: Contains Ant build scripts (generate.xml,generateTarget.xml) to automate the code generation process.output/: The default directory where generated files (e.g.,.dot,.html) are placed based on current examples.META-INF/: Contains the OSGi bundle manifest (MANIFEST.MF), indicating this is structured as an Eclipse plugin.bin/: Compiled Java classes and Acceleo templates.
- Java Development Kit (JDK): Version 17 or later (as specified in
META-INF/MANIFEST.MF). - Eclipse IDE: An Eclipse installation with the Eclipse Modeling Tools (including EMF and Acceleo) is recommended.
- Ant: Required if you want to run the generation using the provided Ant scripts.
-
Explore the Metamodel: Open
model/simplePDL.ecorein your Eclipse IDE (with EMF tooling installed) to understand the structure and concepts of the Simple Process Definition Language. -
Examine Instances: Look at the
.xmifiles in theinstances/directory to see examples of SimplePDL models. You can create your own.xmifiles based on thesimplePDL.ecoremetamodel using an EMF-based editor. -
Run Code Generation:
- Using Ant (Recommended within Eclipse):
- Modify the
tasks/generateTarget.xmlfile if necessary. By default, it points to${basedir}/model/file.xmiwhich might need changing. - Set the
MODELproperty to the path of your input.xmimodel instance (e.g.,value="${basedir}/instances/MakingCoffe.xmi"). - Set the
TARGETproperty to your desired output directory (e.g.,value="${basedir}/output"). The default in the file is${basedir}/src-gen. - Right-click on
tasks/generateTarget.xmlin Eclipse and choose "Run As" > "Ant Build".
- Modify the
- Using Java Application:
- The
src/simplePDL/main/Generate.javaclass includes amainmethod allowing standalone execution. - You can configure a Java Application launch configuration in Eclipse.
- Provide the absolute path to the model file (
.xmi) as the first argument and the absolute path to the target output directory as the second argument. - Ensure the classpath is correctly set up to include all necessary EMF and Acceleo libraries (refer to
tasks/generate.xmlfor a list of required JARs/plugins).
- The
- Using Ant (Recommended within Eclipse):
-
Check Output: The generated files (likely
.dotand.htmlbased on theoutput/folder contents) will appear in the specified target directory.
If you want to create a new Acceleo generation file (.mtl) from scratch within Eclipse:
- Open the Wizard: Go to
File>New>Other.... - Select Acceleo Module: Expand the
Acceleo Model To Textcategory and selectAcceleo Module File. ClickNext. - Fill the Details (referencing the provided image):
- Parent Folder: Browse and select the source folder where you want to create the file (e.g.,
/simplePDL/src/simplePDL/main). - Module Name: Enter a name for your module (e.g.,
generate). This will be the base name of your.mtlfile. - Metamodel URIs: This is crucial. Click the
+button. In the dialog that appears, enter the namespace URI of your metamodel. For this project, it ishttp://www.example.org/simplePDL(found inmodel/simplePDL.ecore). ClickOK. The error message "The list of metamodel URIs... is empty" should disappear. - Template Name: Enter a name for the initial template function that will be created inside the module (e.g.,
generateElement). - Type: Ensure
Templateis selected. - Generate documentation: Check this if you want basic documentation comments generated.
- Generate file: Check this if you want the template to be wrapped in a
[file(...)]block, which directs Acceleo to generate a separate file. This is common for the main template. - Main template: Check this if this template should be the main entry point for generation (annotated with
@main). - Initialize Contents: Check this to generate basic boilerplate code within the template.
- Parent Folder: Browse and select the source folder where you want to create the file (e.g.,
- Finish: Click
Finish. A new.mtlfile will be created in the specified parent folder with the initial content based on your selections.