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

  • Download Eclipse 3.2 on the Eclipse website.
  • Download the bundled version of Acceleo including all the required plugins (the emf-uml2-acceleo bundle).
  • Unzip the Eclipse and the bundle archive in the same directory.
  • Start Eclipse. A new perspective named "Acceleo" should be available.
  • Choosing the Acceleo perspective
    Choosing the Acceleo perspective

  • Acceleo is installed!
  • Eclipse 3.2 with the Acceleo perspective
    Eclipse 3.2 with the Acceleo perspective
    You may install Acceleo with Eclipse 3.1 using the same process.

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.

  • Download the sample module on the Acceleo website and unzip the archive.
  • You should now import the sample projects within Eclipse. Right-click in the explorer view and choose "Import..." then "Existing Project".

    Importing existing projects
    Importing existing projects

  • Three projects are included in the sample generator :
    • 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.

    Selecting the sample projects
    Selecting the sample projects

  • 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.

    UML2 Weblog model
    UML2 Weblog model

    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 can notice that the src directory and the WebContent one are empty right now.

    Project before the code generation
    Project before code generation

  • You may launch the generation process using .chain files. Three .chain files are provided in the project:

    • weblog.chain: launches the generation process using the UML2 model.
    • weblog.clean.chain: cleans the directories before a generation.
    • weblog.uml14.chain: launches the generation process using the UML 1.4 model.
    You can kick-off a .chain file using the "Launch" action in the file context menu.

    Launching the code generation
    Launching the code generation

  • One may then notice that files have appeared in the src and WebContent directories.

    Project after the code generation
    Project after code generation

  • 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.

    Weblog system running
    Weblog system running

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:

    Servlet avant modification
    Servlet before changes are made

    We can add a new behavior between the two tagged lines.

    Servlet after change
    Servlet after changes are made

    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.

These documentations ease the installation and first use of Acceleo. If you need more informations, a 300 pages documentation is available on the Obeo website. Please follow the instructions provided here.

You may also have a look at the reference documentation.

A problem ?

Many ways to solve it :