Quickstart
This quick-start is here to make it very easy for you to catch up with Acceleo. This is not a training course, just a little help to start with.
Installation
First code generation
We will now launch a code generation from a model. In order to do that we will use the sample generation modules provided by the Acceleo team.
free.acceleo-1.1.uml2.gen.java: a code generation module for UML2. This module generates java code from an UML2 model. For each business object it generates data transfer classes (Dto) and classes using JDBC in order to persists data. For each screen it then generates a Jsp file and the required configuration files.
free.acceleo-1.1.uml14.gen.java: a code generation module for UML 1.4. This module generates exactly the same thing than the UML2 one but using an UML 1.4 model. (Many modelers provides UML 1.4 models).
free.acceleo-1.1.demo.weblog: the sample project. In this project you will find the models (UML 1.4 and UML2). You will also find the launching files which will kick off the generation process. The code is generated within this project.
In this tutorial we are using the UML2 meta-model provided by the Eclipse project. This meta-model match the 2.1 specification from the OMG consortium.
Now let's have a look at the sample project (free.acceleo-1.1.demo.weblog).
The UML models can be found in the model directory. These are the design of a blog system. The models are divided in two packages : business defining the business entity of the system (User and BlogEntry) and cinematic defining the software screens and the ways you can navigate from a screen to another.
You can notice that the src directory and the WebContent one are empty right now.
If you want to edit the model using a free modeler, you may for instance install the UML2 modeler provided by the TopCased project
You may launch the generation process using .chain files. Three .chain files are provided in the project:
One may then notice that files have appeared in the src and WebContent directories.
The blog system is generated and is ready for a first try. If you want to try it out you should install the Eclipse Web Tools Platform.
altering generated code
Once the code is generated you can still change the generated code. Acceleo supports incremental generation, it means you can modify the generated source code and then generate code once again without losing the modifications you made. For instance in the validate of the LoginServlet class:
We can add a new behavior between the two tagged lines.
Then you can also change the model (for instance adding new screens, new business entities), generate the code, the user code won't be lost.
This tutorial is just introducing the use of Acceleo. The next tutorial : a first generator tackles the creation of a generator module.
You may also have a look at the documentation section.
A problem?