15
1 Jonathan Musset - [email protected] Acceleo Code Generation Obeo Let's start with an Android example

Acceleo - Let's start with an Android example

Embed Size (px)

DESCRIPTION

--- Eclipse Con 2010 --- Acceleo is a pragmatic implementation of the OMG* standard for code generation called MTL*. Still in incubation state, we plan to have Acceleo graduate for the next Eclipse simultaneous release (Helios).Being an expert at code generation or Acceleo is not necessary to get started on your first code generator : using the Acceleo editor and the powerful features it exposes (completion, syntax highlighting, on-the-fly compilation, quick outline, ...), it is very easy to get started once you understand the most basic principles.This talk presents both the MTL language and the Acceleo Development Toolkit which is provided in the M2T project. Beginners will learn what code generation, M2T, and Acceleo are, as well as how to use them on a concrete case-study. Acceleo addicts will discover the new standard syntax, new functionalities and techniques. We will give you enough of the basics to create your own code generation for a specific target system. We have chosen the Android platform as a target to show that we can also use Acceleo for mobile software.Here is the talk agenda :- Acceleo : What's that new code generation engine?- Create an Android prototype and its corresponding model- Initialize your code generation project from the prototype- Editing your code generation file to make the Android prototype run- Launching your code generation on another model example- Packaging as an eclipse plug-in and for standalone usage- Create new Android applications in few clicks- How to override a specific behavior in the target environment- On the developper side : How to make your own extensions with Acceleo?We'll end the talk with other complex code generation examples made with Acceleo : EEF, UML to Java, Ecore to python, Migrating from a language to another...*OMG : Object Management Group*MTL : Model to Text Language

Citation preview

Page 1: Acceleo - Let's start with an Android example

1

Jonathan Musset - [email protected]

Acceleo Code Generation

Obeo

Let's start with an Android example

Page 2: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Acceleo : what's that new code generation engine?

Meta-model and templates based technology

Implementation of the Model To Text OMG standard (MTL)

Eclipse Modelling / M2T project

Pragmatic approach – How to start from example?

Page 3: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

This is a Quick Tutorial – My goals

Beginners will see a simple but concrete case-study

Acceleo addicts will discover some new killing features

Android experts will learn enough of the basics to be able to create advanced code generator in a few days. As you will see, I'm not an Android expert...

Page 4: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Prototype based approach – Starting from an example

A classic example of Android application : « MyContacts »

« We would like to be able to fully generate the same kind of application »

MyContacts

Page 5: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

The prototype sources and the model

Different kinds of sources to be generated!Java UI, Java DB, XML, properties...

The model must contain all the specific settings of the applicationAndroid Activity, Entity Fields...

One model element « N » generated text parts→

Page 6: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Initialize the Android code generation project

An MTL file for each kind of generated file

Page 7: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Initialize the workflow – The main entry point

An MTL file that calls the other ones... (Mentioned in the OMG specification)

Java / MWE / ANT? Call the Java Standalone API to run the code generation!

Page 8: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Editing the code generator – Quick replacement

Page 9: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Editing the code generator – Quick hierarchy tree

Page 10: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Run and test the generated version of the prototype

MyContacts

Page 11: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Run on other models to create new applications...

Page 12: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

A little bit about incremental generation

« My web service is conserved when I generate the application again »

→ Defining specific coding zones with user tags [protected]

→ Using JMerge with the @generated annotation

Page 13: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Workbench Acceleo views – Edit and maintain!

The « Result View » to show how the text and the model are synchronized

The « Overrides View » to override an existing template behavior

The « Patterns View » to define your own completion proposal

Page 14: Acceleo - Let's start with an Android example

© Copyright Obeo | 22 March, 2010

Let's start with an Android exampleAcceleo Code Generation

Conclusion

Now you can make a complete Android code generator (more widgets...)

We plan to have Acceleo graduate along with the Helios release

Version 3.0 – The last stable release out of Eclipse was 2.x

Page 15: Acceleo - Let's start with an Android example

15

Jonathan Musset - [email protected]

Acceleo Code Generation

Obeo

Let's start with an Android example