Continuous Integration with Maven for Android apps
-
Upload
hugojosefson -
Category
Technology
-
view
7.336 -
download
3
description
Transcript of Continuous Integration with Maven for Android apps
Continuous Integration (CI)with Maven
for Android applications
Hugo Josefson @ GTUG Malmö 2011
Agenda
● What's the problem?– Dependency management
– Developer /Build server mismatch
– Running tests
● Maven & CI– Dependency management
– Developer /Build server mismatch
– Running tests
● DEMO!– How to set up Android apps for Maven
– How to set up Android tests for Maven
– How to set up Continuous Integration
What's the problem?
What's the problem?- Dependency management
• External jars• Hunt down the jars• Where to store them? (svn/git? non-optimal!)• What version was this jar?• What version of other dependency jars does it work with?
– all handled manually
What's the problem?- Dependency management
• Inter-project dependencies• common library jar
– our-common-lib.jar
• several apk projects depend on it– MyApp1.apk– MyApp2.apk
What's the problem?- Developer / Build server mismatch• Script vs IDE for building
– Is the binary built the same way across developers and build servers?
• Script vs IDE for testing– Is the binary tested the same way across
developers and build servers?
What's the problem?- Running tests
• Common excuses– "I don't have time for tests before commit!"– "I can't be bothered with tests before commit!"– “I forgot...”
• Regressions creep in...
Maven
What is Maven?
• A build tool (and more: bit.ly/whatIsMaven)• Default directory structure – overridable• Plugins
Maven as Build Tool
• Tell Maven:– My project is a jar / war / apk / ...– I need library jar commons-lang:2.5
• Maven knows how to build that• Maven knows how to fetch libraries
• (No need to specify directories,nor handle library jars)
MavenDefault Directory Structure
Maven Plugins
• Built-in for core functionality– Building jar– Building war– JavaDoc– Running Tests– … lots more
• Extra for e.g. building / testing / deploying apk– maven-android-plugin
Maven vsDependency management
• External jars Dependency declaration→
<dependency>
<groupId>commons-lang</groupId>
<artifactid>commons-lang</artifactId>
<version>2.5</version>
</dependency>
Maven vsDependency management
• Inter-project dependencies Dep. declaration→– Example: morse-lib by Manfred Moser
Maven vsDeveloper / Build server mismatch
• Solved when both use same build and test tool– Build server can use Maven– Developer can use Maven– Maven builds and runs tests in one go– Reproducible Same build result→
DEMO TIME!
How to set up
Android apps for Maven
[DEMO]
How to set up
Android tests for Maven
[DEMO]
How to set up
Continuous Integration
[DEMO]
Jenkins + Android SDKAndroid Emulator Plugin
Maven project
Maven Android resources
Getting Started + discussion group:http://code.google.com/p/maven-android-plugin
Google: maven android
Questions?
Extra stuff
(if time allows)
Robotium
• Write UI tests for Android easily with Robotium– www.robotium.org– Standalone jar (Apache License 2)– Makes it easier to write instrumentation tests– Handles all the hard stuff:
– Toasts, Context menus, Timing issues,following current Activity...
Robotium, cont'd...
• Write UI tests for Android easily with Robotium– www.robotium.org– Use normal instrumentation test class, e.g.
ActivityInstrumentationTestCase2
– Some Maven-enabled robotium-samplesgit clone --recursive \git://github.com/jayway/robotium-samples.git
Multi-module projects
• Share code & resources between Android apps– Share code + Java resources
Dependency to jar→
– Share Android resources Dependency to apklib→» ApkLib on maven-android-plugin wiki
» libraryprojects/ in Samples (beta)