Your SlideShare is downloading. ×
Building Android apps with Maven
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Building Android apps with Maven

7,855
views

Published on

An overview of the Android Maven Plugin.

An overview of the Android Maven Plugin.

Published in: Technology, Lifestyle

1 Comment
24 Likes
Statistics
Notes
No Downloads
Views
Total Views
7,855
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
412
Comments
1
Likes
24
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Building Android apps with MavenFabrizio GiudiciSenior Java ArchitectTidalwave, NetBeans Dream Team
    • 2. Agenda 2
    • 3. Agenda• Introducing Maven 2
    • 4. Agenda• Introducing Maven• The Android Plugin for Maven 2
    • 5. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
    • 6. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
    • 7. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
    • 8. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project 2
    • 9. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project• Maven: why and when? 2
    • 10. Agenda• Introducing Maven• The Android Plugin for Maven• A real world project• Maven: why and when?• Question time 2
    • 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. About Fabrizio 3
    • 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. 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. 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. 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. Introducing Maven Maven in four slides!
    • 18. Maven vs Ant 5
    • 19. Maven vs Ant• Maven is truly like cats 5
    • 20. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
    • 21. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
    • 22. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
    • 23. Maven vs Ant• Maven is truly like cats –“Cats, either you love them or hate them” 5
    • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Phases, plugins, goals 6
    • 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. 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. 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. 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. 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. Artifacts and repositories 7
    • 41. Artifacts and repositories• A project is usually composed by many modules 7
    • 42. Artifacts and repositories• A project is usually composed by many modules• Each module 7
    • 43. Artifacts and repositories• A project is usually composed by many modules• Each module –possibly depends on other modules’ artifacts 7
    • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Project structure 8
    • 55. Project structure• Master POM Master POM 8
    • 56. Project structure• Master POM• Includes Module POMs includes Master POM Module 1 POM Modules Module 2 POM POM Module 3 POM 8
    • 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. 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. 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. The AndroidPlugin for Maven
    • 61. The maven-android-plugin 10
    • 62. The maven-android-plugin• maven-android-plugin 10
    • 63. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) 10
    • 64. The maven-android-plugin• maven-android-plugin –Also android-maven-plugin (3.0) –Made by Jayway (jayway.se), FLOSS 10
    • 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. 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. 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. 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. 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. 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. 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. 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. The MorseFlash demo app 11
    • 74. The MorseFlash demo app• A very simple application, perfect starter 11
    • 75. The MorseFlash demo app• A very simple application, perfect starter –Generates Morse signals out of a word 11
    • 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. 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. 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. 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. 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. 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. 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. 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. 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. A real world project blueBill Mobile
    • 86. blueBill Mobile 14
    • 87. blueBill Mobile• For bird(watch)ers 14
    • 88. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field 14
    • 89. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources 14
    • 90. blueBill Mobile• For bird(watch)ers –Record geotagged observations on the field –Browse fact sheets and multimedia resources• Sophisticated data structure 14
    • 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. 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. 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. 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. 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. 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. POM samples• Super POM•<dependencyManagement> 15
    • 98. QA 16
    • 99. QA• Test coverage (e.g. Cobertura) 16
    • 100. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs) 16
    • 101. QA• Test coverage (e.g. Cobertura)• Static analysis (e.g. FindBugs)• You just need to configure the proper plugin 16
    • 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. 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. 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. Continuous Integration with Hudson 17
    • 106. Continuous Integration with Hudson• CI is a well known best practice 17
    • 107. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA” 17
    • 108. Continuous Integration with Hudson• CI is a well known best practice –“continuously applying QA”• Should be automated 17
    • 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. 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. 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. Release 18
    • 113. Release• Maven manages a standard release workflow 18
    • 114. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) 18
    • 115. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks 18
    • 116. Release• Maven manages a standard release workflow –Automatically handles versioning (SNAPSHOT, ...) –Performs some consistency checks –Customizable 18
    • 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. 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. 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. Advanced stuff, tricks and tweaks 19
    • 121. Advanced stuff, tricks and tweaks• They say that Maven is not flexible 19
    • 122. Advanced stuff, tricks and tweaks• They say that Maven is not flexible• It’s not true 19
    • 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. 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. 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. 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. Preprocessing AndroidManifest.xml 20
    • 128. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle 20
    • 129. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production 20
    • 130. Preprocessing AndroidManifest.xml• blueBill Mobile release cycle –production –alpha: can be installed side-by-side, uses separate workarea 20
    • 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. 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. 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. 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. 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. 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. 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. 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. Patching jars 21
    • 140. Patching jars• Sometimes you might need to patch some library 21
    • 141. Patching jars• Sometimes you might need to patch some library –Use some JSE runtime classes not available in Android 21
    • 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. 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. 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. 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. 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. Reusing R.java (pre-4.0 trick) 22
    • 148. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK 22
    • 149. Reusing R.java (pre-4.0 trick)• R.java is automatically generated by the SDK –It contains constants referring to resources 22
    • 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. 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. 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. 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. 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. 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. 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. 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. Why and when? Evaluating whether Maven is the good choice for you
    • 159. Maven is about knowledge reuse 24
    • 160. Maven is about knowledge reuse• According to the Merriam-Webster: 24
    • 161. Maven is about knowledge reuse• According to the Merriam-Webster: –“maven: one who is experienced or knowledgeable” 24
    • 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. 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. 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. Benefits of Maven 25
    • 166. Benefits of Maven• Have a standard project structure for everything 25
    • 167. Benefits of Maven• Have a standard project structure for everything –For JSE, JEE, Android, NetBeans Platform, ... 25
    • 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. 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. 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. 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. 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. 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. 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. 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. Is Maven the right tool for you? 26
    • 177. Is Maven the right tool for you?• Undoubtedly Maven is more complex 26
    • 178. Is Maven the right tool for you?• Undoubtedly Maven is more complex –in the “entropic” meaning (needed known things) 26
    • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Question time ... and thanks for your attention! fabrizio.giudici@tidalwave.it http://weblogs.java.net/blog/fabriziogiudici http://fabriziogiudici.it