Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

24

Share

Download to read offline

Building Android apps with Maven

Download to read offline

An overview of the Android Maven Plugin.

Related Books

Free with a 30 day trial from Scribd

See all

Building Android apps with Maven

  1. 1. Building Android apps with MavenFabrizio GiudiciSenior Java ArchitectTidalwave, NetBeans Dream Team
  2. 2. Agenda 2
  3. 3. Agenda• Introducing Maven 2
  4. 4. Agenda• Introducing Maven• The Android Plugin for Maven 2
  5. 5. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
  6. 6. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
  7. 7. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
  8. 8. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
  9. 9. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project• Maven: why and when? 2
  10. 10. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project• Maven: why and when?• Question time 2
  11. 11. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project• Maven: why and when?• Question time• Thanks to Manfred Moser (Simpligility) for providing some preso stuff 2
  12. 12. About Fabrizio 3
  13. 13. About Fabrizio• Senior Architect, Mentor, Technical Writer –Working with Java (all the editions, plus exotic stuff) since 1996 –Frequent speaker at J1, Devoxx, Jazoon, JUGs –Blogger at Java.Net, Most Valuable Blogger at DZone• Member of the NetBeans Dream Team 3
  14. 14. About Fabrizio• Senior Architect, Mentor, Technical Writer –Working with Java (all the editions, plus exotic stuff) since 1996 –Frequent speaker at J1, Devoxx, Jazoon, JUGs –Blogger at Java.Net, Most Valuable Blogger at DZone• Member of the NetBeans Dream Team• Co-leader of JUG Milano 3
  15. 15. About Fabrizio• Senior Architect, Mentor, Technical Writer –Working with Java (all the editions, plus exotic stuff) since 1996 –Frequent speaker at J1, Devoxx, Jazoon, JUGs –Blogger at Java.Net, Most Valuable Blogger at DZone• Member of the NetBeans Dream Team• Co-leader of JUG Milano• In the past years shifting from “mere” design and architecture... 3
  16. 16. About Fabrizio• Senior Architect, Mentor, Technical Writer –Working with Java (all the editions, plus exotic stuff) since 1996 –Frequent speaker at J1, Devoxx, Jazoon, JUGs –Blogger at Java.Net, Most Valuable Blogger at DZone• Member of the NetBeans Dream Team• Co-leader of JUG Milano• In the past years shifting from “mere” design and architecture...• ... to method & software factory optimization 3
  17. 17. Introducing Maven Maven in four slides!
  18. 18. Maven vs Ant 5
  19. 19. Maven vs Ant• Maven is truly like cats 5
  20. 20. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
  21. 21. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
  22. 22. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
  23. 23. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
  24. 24. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them”• Ant: a scripting interpreter, build-oriented DSL 5
  25. 25. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL 5
  26. 26. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor 5
  27. 27. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative 5
  28. 28. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative• POM: Project Object Model 5
  29. 29. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative• POM: Project Object Model –Project structure, language, packaging 5
  30. 30. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative• POM: Project Object Model –Project structure, language, packaging –Dependencies 5
  31. 31. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative• POM: Project Object Model –Project structure, language, packaging –Dependencies –Other metadata (license, developers, mailing list, etc...) 5
  32. 32. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative• POM: Project Object Model –Project structure, language, packaging –Dependencies –Other metadata (license, developers, mailing list, etc...)• Plugin oriented 5
  33. 33. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” procedural• Ant: a scripting interpreter, build-oriented DSL• Maven: a standard build workflow executor declarative• POM: Project Object Model –Project structure, language, packaging –Dependencies –Other metadata (license, developers, mailing list, etc...)• Plugin oriented• FLOSS (Apache License v2.0) 5
  34. 34. Phases, plugins, goals 6
  35. 35. Phases, plugins, goals• A lifecycle is a sequence of phases validate The compile test “defa package ult” l integration-test verify ifecy install c le deploy 6
  36. 36. Phases, plugins, goals• A lifecycle is a sequence of phases• Every plugin can execute goals compiler validate plugin surefire The compile compile plugin test “defa package test deploy ult” l integration-test verify plugin ifecy install deploy c le deploy 6
  37. 37. Phases, plugins, goals• A lifecycle is a sequence of phases• Every plugin can execute goals mvn compiler:compile• Goals can be executed manually... compiler validate plugin surefire The compile compile plugin test “defa package test deploy ult” l integration-test verify plugin ifecy install deploy c le deploy 6
  38. 38. Phases, plugins, goals• A lifecycle is a sequence of phases• Every plugin can execute goals mvn compiler:compile• Goals can be executed manually...• ... or attached to phases compiler validate plugin surefire The compile compile plugin test “defa package test deploy ult” l integration-test verify plugin ifecy install deploy c le deploy 6
  39. 39. Phases, plugins, goals• A lifecycle is a sequence of phases• Every plugin can execute goals mvn compiler:compile• Goals can be executed manually...• ... or attached to phases mvn install compiler validate plugin surefire The compile compile plugin test “defa package test deploy ult” l integration-test verify plugin ifecy install deploy c le deploy 6
  40. 40. Artifacts and repositories 7
  41. 41. Artifacts and repositories• A project is usually composed by many modules 7
  42. 42. Artifacts and repositories• A project is usually composed by many modules• Each module 7
  43. 43. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts 7
  44. 44. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files) 7
  45. 45. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact 7
  46. 46. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact –has got unique coordinates 7
  47. 47. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact –has got unique coordinates • groupId, artifactId, version, packaging, classifier 7
  48. 48. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact –has got unique coordinates • groupId, artifactId, version, packaging, classifier –can be retrieved from a local/remote repository 7
  49. 49. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact –has got unique coordinates • groupId, artifactId, version, packaging, classifier –can be retrieved from a local/remote repository –can be deployed to a local/remote repository 7
  50. 50. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact mvn install mvn deploy –has got unique coordinates • groupId, artifactId, version, packaging, classifier –can be retrieved from a local/remote repository –can be deployed to a local/remote repository 7
  51. 51. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact mvn install mvn deploy –has got unique coordinates • groupId, artifactId, version, packaging, classifier –can be retrieved from a local/remote repository –can be deployed to a local/remote repository• Local repo is at $HOME/.m2/repository 7
  52. 52. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact mvn install mvn deploy –has got unique coordinates • groupId, artifactId, version, packaging, classifier –can be retrieved from a local/remote repository –can be deployed to a local/remote repository• Local repo is at $HOME/.m2/repository• Remote repo is the internet, or your own, or both 7
  53. 53. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts –produces its own artifact (maybe made of multiple files)• Each artifact mvn install mvn deploy –has got unique coordinates • groupId, artifactId, version, packaging, classifier –can be retrieved from a local/remote repository –can be deployed to a local/remote repository• Local repo is at $HOME/.m2/repository• Remote repo is the internet, or your own, or both 7
  54. 54. Project structure 8
  55. 55. Project structure• Master POM Master POM 8
  56. 56. Project structure• Master POM• Includes Module POMs includes Master POM Module 1 POM Modules Module 2 POM POM Module 3 POM 8
  57. 57. Project structure• Master POM• Includes Module POMs includes inherits• POMs can inherit Master POM Module 1 POM Modules Module 2 POM POM Module 3 POM 8
  58. 58. Project structure• Master POM• Includes Module POMs includes inherits• POMs can inherit –DRY Master POM Module 1 POM Modules Module 2 POM POM Module 3 POM 8
  59. 59. Project structure• Master POM Super• Includes Module POMs POM includes inherits• POMs can inherit –DRY Master• A Super POM is really POM Module 1 POM valuable Modules Module 2 POM POM Module 3 POM 8
  60. 60. The AndroidPlugin for Maven
  61. 61. The maven-android-plugin 10
  62. 62. The maven-android-plugin• maven-android-plugin 10
  63. 63. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) 10
  64. 64. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS 10
  65. 65. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools 10
  66. 66. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: 10
  67. 67. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: –generate-sources, apk, apklib, dex, zipalign, unpack 10
  68. 68. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: –generate-sources, apk, apklib, dex, zipalign, unpack –deploy, deploy-dependencies, redeploy, undeploy 10
  69. 69. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: –generate-sources, apk, apklib, dex, zipalign, unpack –deploy, deploy-dependencies, redeploy, undeploy –emulator-start, emulator-stop, run 10
  70. 70. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: –generate-sources, apk, apklib, dex, zipalign, unpack –deploy, deploy-dependencies, redeploy, undeploy –emulator-start, emulator-stop, run –push, pull 10
  71. 71. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: –generate-sources, apk, apklib, dex, zipalign, unpack –deploy, deploy-dependencies, redeploy, undeploy –emulator-start, emulator-stop, run –push, pull• Supports native development (NDK) 10
  72. 72. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS• Makes it possible to call Android SDK tools• Goals: –generate-sources, apk, apklib, dex, zipalign, unpack –deploy, deploy-dependencies, redeploy, undeploy –emulator-start, emulator-stop, run –push, pull• Supports native development (NDK) –Not covered in this talk 10
  73. 73. The MorseFlash demo app 11
  74. 74. The MorseFlash demo app• A very simple application, perfect starter 11
  75. 75. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word 11
  76. 76. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later) 11
  77. 77. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs 11
  78. 78. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs –The Master POM 11
  79. 79. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs –The Master POM –The Library (pure JSE code for Morse coding) 11
  80. 80. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs –The Master POM –The Library (pure JSE code for Morse coding) –The application 11
  81. 81. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs –The Master POM –The Library (pure JSE code for Morse coding) –The application –Integration tests 11
  82. 82. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs –The Master POM –The Library (pure JSE code for Morse coding) –The application –Integration tests• Includes support for signing and obfuscating 11
  83. 83. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word –Note that the POMs are naive (more later)• Made of four POMs –The Master POM –The Library (pure JSE code for Morse coding) –The application –Integration tests• Includes support for signing and obfuscating• Two profiles, “standard” and “release” 11
  84. 84. Android Libraries• Support for Android apklib –zipped file with both code and resources (including R.java) –can be used for reusing code• The Android Maven plugin supports it –even though sources are not layout in the standard way• Personally I don’t like it• More about reusing libraries later 12
  85. 85. A real world project blueBill Mobile
  86. 86. blueBill Mobile 14
  87. 87. blueBill Mobile• For bird(watch)ers 14
  88. 88. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field 14
  89. 89. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources 14
  90. 90. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure 14
  91. 91. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure –RDF, semantic web 14
  92. 92. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure –RDF, semantic web• Reuses code from JSE and JEE projects 14
  93. 93. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure –RDF, semantic web• Reuses code from JSE and JEE projects• Uses some libraries from the NetBeans Platform 14
  94. 94. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure –RDF, semantic web• Reuses code from JSE and JEE projects• Uses some libraries from the NetBeans Platform –for implementing DCI (Data, Context, Interaction) 14
  95. 95. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure –RDF, semantic web• Reuses code from JSE and JEE projects• Uses some libraries from the NetBeans Platform –for implementing DCI (Data, Context, Interaction)• 3 projects (core, resources, Android app) 14
  96. 96. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure –RDF, semantic web• Reuses code from JSE and JEE projects• Uses some libraries from the NetBeans Platform –for implementing DCI (Data, Context, Interaction)• 3 projects (core, resources, Android app)• 48 modules 14
  97. 97. POM samples• Super POM•<dependencyManagement> 15
  98. 98. QA 16
  99. 99. QA• Test coverage (e.g. Cobertura) 16
  100. 100. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs) 16
  101. 101. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs)• You just need to configure the proper plugin 16
  102. 102. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs)• You just need to configure the proper plugin –Reuse a Super POM! 16
  103. 103. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs)• You just need to configure the proper plugin –Reuse a Super POM!• Same configuration for all kind of projects 16
  104. 104. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs)• You just need to configure the proper plugin –Reuse a Super POM!• Same configuration for all kind of projects• See some examples 16
  105. 105. Continuous Integration with Hudson 17
  106. 106. Continuous Integration with Hudson• CI is a well known best practice 17
  107. 107. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA” 17
  108. 108. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA”• Should be automated 17
  109. 109. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA”• Should be automated –CI server (Hudson/Jenkins the most popular) 17
  110. 110. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA”• Should be automated –CI server (Hudson/Jenkins the most popular)• See some examples 17
  111. 111. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA”• Should be automated –CI server (Hudson/Jenkins the most popular)• See some examples 17
  112. 112. Release 18
  113. 113. Release• Maven manages a standard release workflow 18
  114. 114. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) 18
  115. 115. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks 18
  116. 116. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks –Customizable 18
  117. 117. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks –Customizable• Distribution artifacts can be deployed to a repo 18
  118. 118. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks –Customizable• Distribution artifacts can be deployed to a repo• Releasing can be performed by Hudson 18
  119. 119. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks –Customizable• Distribution artifacts can be deployed to a repo• Releasing can be performed by Hudson –“Push a button” release 18
  120. 120. Advanced stuff, tricks and tweaks 19
  121. 121. Advanced stuff, tricks and tweaks• They say that Maven is not flexible 19
  122. 122. Advanced stuff, tricks and tweaks• They say that Maven is not flexible• It’s not true 19
  123. 123. Advanced stuff, tricks and tweaks• They say that Maven is not flexible• It’s not true• It’s flexible if you work in its way 19
  124. 124. Advanced stuff, tricks and tweaks• They say that Maven is not flexible• It’s not true• It’s flexible if you work in its way• Some examples in the following slides 19
  125. 125. Advanced stuff, tricks and tweaks• They say that Maven is not flexible• It’s not true• It’s flexible if you work in its way• Some examples in the following slides –Maybe overkill 19
  126. 126. Advanced stuff, tricks and tweaks• They say that Maven is not flexible• It’s not true• It’s flexible if you work in its way• Some examples in the following slides –Maybe overkill –Maybe tweaks 19
  127. 127. Preprocessing AndroidManifest.xml 20
  128. 128. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle 20
  129. 129. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production 20
  130. 130. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea 20
  131. 131. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea 20
  132. 132. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles 20
  133. 133. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles –Automatically set versionName from POM 20
  134. 134. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles –Automatically set versionName from POM –Automatically set versionCode 20
  135. 135. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles –Automatically set versionName from POM –Automatically set versionCode –Use different appPackage, label and icon 20
  136. 136. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles –Automatically set versionName from POM –Automatically set versionCode –Use different appPackage, label and icon• Can be done with android:manifest-update goal 20
  137. 137. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles –Automatically set versionName from POM –Automatically set versionCode –Use different appPackage, label and icon• Can be done with android:manifest-update goal• Can be done in other ways 20
  138. 138. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea –beta: can be installed side-by-side, uses same workakea• Multiple profiles –Automatically set versionName from POM –Automatically set versionCode –Use different appPackage, label and icon• Can be done with android:manifest-update goal• Can be done in other ways –e.g. the Groovy Maven plugin 20
  139. 139. Patching jars 21
  140. 140. Patching jars• Sometimes you might need to patch some library 21
  141. 141. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android 21
  142. 142. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android –Some Swing stuff, XML stuff (for older Android versions) 21
  143. 143. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android –Some Swing stuff, XML stuff (for older Android versions)• maven-shade-plugin 21
  144. 144. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android –Some Swing stuff, XML stuff (for older Android versions)• maven-shade-plugin –filters: strip some classes out of a jar 21
  145. 145. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android –Some Swing stuff, XML stuff (for older Android versions)• maven-shade-plugin –filters: strip some classes out of a jar –relocations: change class references in the bytecode 21
  146. 146. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android –Some Swing stuff, XML stuff (for older Android versions)• maven-shade-plugin –filters: strip some classes out of a jar –relocations: change class references in the bytecode• See the code example 21
  147. 147. Reusing R.java (pre-4.0 trick) 22
  148. 148. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK 22
  149. 149. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources 22
  150. 150. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values 22
  151. 151. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables 22
  152. 152. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables –two R.java’s from two modules are likely to collide 22
  153. 153. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables –two R.java’s from two modules are likely to collide –changed in Android 4.0 22
  154. 154. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables –two R.java’s from two modules are likely to collide –changed in Android 4.0• What to do? 22
  155. 155. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables –two R.java’s from two modules are likely to collide –changed in Android 4.0• What to do?• maven-rindirect-plugin 22
  156. 156. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables –two R.java’s from two modules are likely to collide –changed in Android 4.0• What to do?• maven-rindirect-plugin –generates an “indirect” R.java which delegates 22
  157. 157. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources –“progressive” values –uh oh: javac inlines static final variables –two R.java’s from two modules are likely to collide –changed in Android 4.0• What to do?• maven-rindirect-plugin –generates an “indirect” R.java which delegates• Or a trick with the maven-replacer-plugin 22
  158. 158. Why and when? Evaluating whether Maven is the good choice for you
  159. 159. Maven is about knowledge reuse 24
  160. 160. Maven is about knowledge reuse• According to the Merriam-Webster: 24
  161. 161. Maven is about knowledge reuse• According to the Merriam-Webster: –“maven: one who is experienced or knowledgeable” 24
  162. 162. Maven is about knowledge reuse• According to the Merriam-Webster: –“maven: one who is experienced or knowledgeable”• Reuse by inheritance and composition 24
  163. 163. Maven is about knowledge reuse• According to the Merriam-Webster: –“maven: one who is experienced or knowledgeable”• Reuse by inheritance and composition• It’s about putting your and others’ experience into your build system and reuse it 24
  164. 164. Maven is about knowledge reuse• According to the Merriam-Webster: –“maven: one who is experienced or knowledgeable”• Reuse by inheritance and composition• It’s about putting your and others’ experience into your build system and reuse it –the Super POM 24
  165. 165. Benefits of Maven 25
  166. 166. Benefits of Maven• Have a standard project structure for everything 25
  167. 167. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ... 25
  168. 168. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI 25
  169. 169. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later) 25
  170. 170. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later)• Have a standard release workflow 25
  171. 171. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later)• Have a standard release workflow• Easily include libraries, manage dependencies 25
  172. 172. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later)• Have a standard release workflow• Easily include libraries, manage dependencies –Reporting! 25
  173. 173. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later)• Have a standard release workflow• Easily include libraries, manage dependencies –Reporting!• IDE neutral 25
  174. 174. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later)• Have a standard release workflow• Easily include libraries, manage dependencies –Reporting!• IDE neutral• CLI just works as the IDE 25
  175. 175. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ...• Have a standard build workflow and CI –Test coverage, static analysis, ... (more later)• Have a standard release workflow• Easily include libraries, manage dependencies –Reporting!• IDE neutral• CLI just works as the IDE• Language neutral (e.g. Scala, Groovy, ...) 25
  176. 176. Is Maven the right tool for you? 26
  177. 177. Is Maven the right tool for you?• Undoubtedly Maven is more complex 26
  178. 178. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) 26
  179. 179. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple 26
  180. 180. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it 26
  181. 181. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well 26
  182. 182. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it 26
  183. 183. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects 26
  184. 184. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects –might be overkill 26
  185. 185. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects –might be overkill –but it’s a matter of reusing knowledge 26
  186. 186. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects –might be overkill –but it’s a matter of reusing knowledge• For companies 26
  187. 187. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects –might be overkill –but it’s a matter of reusing knowledge• For companies –it’s a must (think of modularization, CI, quality) 26
  188. 188. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects –might be overkill –but it’s a matter of reusing knowledge• For companies –it’s a must (think of modularization, CI, quality) –some infrastructure needed (e.g. Nexus) 26
  189. 189. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) –simple things are reasonably simple –but you’ll need time to master it• Most of people whining about Maven don’t know it well –but we’ve got different minds and you might not like it• For single developers / very simple projects –might be overkill –but it’s a matter of reusing knowledge• For companies –it’s a must (think of modularization, CI, quality) –some infrastructure needed (e.g. Nexus) 26
  190. 190. Resources• http://maven.apache.org• http://sonatype.com/Support/Books• http://code.google.com/p/maven-android-plugin• http://code.google.com/p/robotium• http://simpligility.com/2011/11/apache-maven-at-andevcon-ii• http://bluebill.tidalwave.it/mobile• http://kenai.com/projects/nbandroid• http://rgladwell.github.com/m2e-android/• http://code.google.com/p/robotium/• http://github.com/akquinet/android-rindirect 27
  191. 191. Question time ... and thanks for your attention! fabrizio.giudici@tidalwave.it http://weblogs.java.net/blog/fabriziogiudici http://fabriziogiudici.it
  • hyoungseunglee

    Mar. 1, 2015
  • webmart

    Dec. 22, 2014
  • loind89

    Dec. 9, 2013
  • sahasbhop

    Jun. 8, 2013
  • mhaidarhanif

    Mar. 10, 2013
  • darjeeling

    Jan. 15, 2013
  • TinTinHvmtltsmmnh

    Jan. 14, 2013
  • natxoska

    Nov. 13, 2012
  • JamesElsey

    Jul. 13, 2012
  • natanaelfonseca

    Apr. 5, 2012
  • swung

    Nov. 27, 2011
  • dcwang2005

    Nov. 27, 2011
  • duydo

    Nov. 25, 2011
  • thofmann

    Nov. 25, 2011
  • marco.floripa

    Nov. 25, 2011
  • malonso1976

    Nov. 25, 2011
  • ulinkwo

    Nov. 25, 2011
  • wsaputra

    Nov. 25, 2011
  • suiaing

    Nov. 25, 2011
  • anthonydahanne

    Nov. 24, 2011

An overview of the Android Maven Plugin.

Views

Total views

9,641

On Slideshare

0

From embeds

0

Number of embeds

548

Actions

Downloads

454

Shares

0

Comments

0

Likes

24

×