Acceleo Code Generation

6 368 vues

Publié le

0 commentaire
0 j’aime
Statistiques
Remarques
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Aucun téléchargement
Vues
Nombre de vues
6 368
Sur SlideShare
0
Issues des intégrations
0
Intégrations
3 193
Actions
Partages
0
Téléchargements
64
Commentaires
0
J’aime
0
Intégrations 0
Aucune incorporation

Aucune remarque pour cette diapositive

Acceleo Code Generation

  1. 1. AcceleoCode Generation From the model to the Android app Stéphane Bégaudeau stephane.begaudeau@obeo.fr Gaël Blondelle gael.blondelle@obeo.fr
  2. 2. Goals of the tutorial
  3. 3. Goals of the tutorial Beginners See a simple concrete case studyAcceleo addicts Discover new killing featuresAndroid experts Learn enough to build a full fledged generator
  4. 4. I m not an Android development expert
  5. 5. 1. Acceleo:A new code generator
  6. 6. A long history...From Acceleo.org in 2006... ...to Eclipse.org in 2009 Version 3.0 is part of the Eclipse Helios rele ase train
  7. 7. A long history... Acceleo 3 Acceleo 2
  8. 8. A new code generationlanguage Implementation Metamodel and of the Model To templates based Text OMG technology standard (MTL) Tooling to help Eclipse Modeling starting a new / M2T Project generator from scratch 8
  9. 9. The Acceleo SDK Acceleo Development Tools = + Acceleo Runtime (Compiler + Engine) Eclipse independant: can be run anywhere (plain old Jar, 9 OSGi, Eclipse...)
  10. 10. 2.Prototype basedapproach
  11. 11. Lets have a look at the Android prototype
  12. 12. Unlock the power of your models Java UI Java DB Different kinds of source artifacts to be generated XML Properties 12
  13. 13. Good PracticeOn e kind of f ile to be gen erated... L file to b e created...one MT 13
  14. 14. t, databas e adapter,Manifes n p a g e,properties file, editio e dition pag e layout...
  15. 15. A little bit of syntax Header 15
  16. 16. A little bit of syntax B o dy 16
  17. 17. A little bit of syntaxTemplates are better for generating text and return a stringQueries can return any kind of objects You can call Java services from a template or a query The result of a query is stored in a cache. 17
  18. 18. The workflow file ion a nnotat @main The MTL file calling the other ones 18
  19. 19. Initialize the generation project 1. Create new Acceleo project 2. Use the wizard (update file paths) 3. Create a workflow file 19
  20. 20. 3... 2... 1... Anything Launch Generated that canconfiguration Java Main launch Java... SameStand VM as Standalone Standalonealone Eclipse 20
  21. 21. Ignition 1. Launch the generator (launch config as Eclipse plugin) 21
  22. 22. From a static generator... … to a dyna mic one3.
  23. 23. Quick replacement Select a text section in the template, then hit "Content Assist" hotkeys 23
  24. 24. Hierarchy Tree Select a text section in the template, then right-click "Source > As For/If" 24
  25. 25. Good Practice " i s qu i c k b ut dirty..."As For/If ...use template ymorphism instead!! pol 25
  26. 26. Generation patternsUse the Generation Patterns View 26
  27. 27. Extract as S elect a text section in the template, then right click "Refactor > Extract as template" template 27
  28. 28. RefactoringAlt + Shift + R 28
  29. 29. Launch the generator - open the Result view - launch config as Eclipse plugin - activate the Traceability Have a look at the Result view
  30. 30. 4.Make the Android App run 30
  31. 31. Debug your templatesThanks to Acceleo debugger 31
  32. 32. Configure theAndroid Development Kit Set the path to the SDK location Create a new A ndroid Virtual Device - AVD 32
  33. 33. Turn on the phone 33
  34. 34. 5.A generic Android App generator 34
  35. 35. Create a fresh new model
  36. 36. Generate new Android Apps 36
  37. 37. 6.A new App in a few clicks 37
  38. 38. Packaging and deployingGenerate an Eclipse Add an action on UI plugin right-click on models Synchronize your Create a builder code and your model 38
  39. 39. Packaging settings Filename pattern of the model Target folder of the generation Warning Eclipse specific 39
  40. 40. Workout 1. Create new Acceleo UI project 2. Use the wizard nd 3. Launch a 2 Eclipse Runtime and test 40
  41. 41. 7.Override specific behavior 41
  42. 42. Overriding existing generators Eclipse-o nly Static Dynamic overriding overriding 42
  43. 43. Overriding behavior Module A Template MT es rrid Imports Module Cove Extends Module B C invok es MT, B.MT Template wi ll be executed MT 43
  44. 44. Lost code A common problem with code generators... if you change the generated code... your modifications are lost during the next generation. 44
  45. 45. Protected area Will not be erased after re-generation Dont forget the comments marks...© Copyright 2010 ... and the ID Obeo 45
  46. 46. @Generated Acceleo also uses JMerge You can protect a whole block with a simple comment
  47. 47. 8.© Copyright 2010 Obeo The next step: Acceleo 3.1 47
  48. 48. © Copyright 2010 Obeo48 Documentation
  49. 49. © Copyright 2010 Obeo49 UI Improvements
  50. 50. Thank you for your attention! Questions?

×