[Android Software Development] android_owl:
http://maven.apache.org/​

Hello dear reader,

you may ask yourself now "Great name, but what is it?": it is a top level project from the apache software foundation and is used on an enterprise level for the following (Warning: this thread is about serious app development - it's about best practices and technologies which'll help you to get your job done in time - nothing else):

Convention over configuration focus for the complete development process

Unified project setup and structure

Project management based on a POM (project object model)

Dependency management

Unified building process with extensive plugin support (even your legacy ant-scripts, jey!)

IDE independent, but most of them support it really well

Much more, take a look at: http://maven.apache.org/maven-features.html

Benefits of using Maven

Unified project setup and structure

You get a default place for your source, for your tests and your (config-, etc)-resources.

Project management based on a POM

http://maven.apache.org/pom.html#What_is_the_POM

Project dependent, environment independent configuration (JDK-Version, Parent/Children relationships between maven projects)

Dependency management

You need a library to connect to your RESTful-Webservice or your favorite plain old java technologie? You've just have to define a dependency in your pom.xml and let maven download your desired lib automatically - without taking care about where to get version x. You can also download the source (if you want to understand how the lib works) or the documentation. This alone can save hours.

Unified building process with extensive plugin support

Generate a complete documentation based on your javadoc comments, compile your apps and deploy them to whereever you want and how. There are defaults (which you should use) but if you need to deploy your webarchive on that floppy, you can do it.

IDE independent

If you want to use it on the CLI, you can do it - but if you're busy you can get plugins for all the major IDEs out there:

Eclipse - http://maven.apache.org/plugins/maven-eclipse-plugin/ (already integrated in spring toolsuite)

IntelliJ IDEA - Already integrated

Netbeans - http://maven.apache.org/netbeans-module.html

How to create an android app with maven and eclipse

Get the last Eclipse distro or use your existing one ( version >= 3.6 )

Get the last AndroidSDK or use your existing one

Install the last maven-integration-plugin for eclipse (m2e)

Install the last m2e-configurator-plugin for eclipse

Get the latest archetypes for android-projects from http://repo1.maven.org/maven2/archetype-catalog.xml and integrate them into your maven installation

Create a new maven project, select the android-archetype, enter your ids and click on finish.

Step 5.) How to integrate the archetype into m2e?

Download the archetype-catalog.xml or copy the URL (local installation)

Open an eclipse instance, click on the menuitem called "Window" -> "Preferences"

Click on the "Maven" link from the treeview on the left, choose archetypes

Add your xml file: "Add Local Catalog" for local installation or "Add Remote Catalog" to get the catalog from the webserver (preferred).

Step 6.) Create a new maven project with android-support

There are two ways to finish this step.

Create an android project and add the maven nature (easy)

Create an maven project and choose an android-archetype (preferred)

Open the "New" - Context from eclipse with a right click on your workspace -> "New" -> "Other..."

Look for the Maven directory -> choose "Maven project"

Use the default values (dont skip the archetype selection)

Type "android" into the filter textbox

Choose the item with the Artifact ID of android-release

Enter your Group Id (your packagename for example (org.test)), your Artifact Id (app) - the package name will be Group Id + Artifact Id)

You've to create the directory structure: "src/test/java"

Questions

Are there any disadvantages?

You shouldn't use maven if you're a beginner in Java-Development. There is quite a learning curve to understand the concepts and of course the usage. It's easier to understand the whole approach if you're familiar with project management, enterprise architecture and optionally continuous integration.

Should I use maven?

Of course! Just kidding, there are several factors which one can decide, based on: Do you want to...

use dependency management?

work with other people on this project?

take benefit of software-architecture based on parent-child relationships between your projects (stop copying your code)

use automated builds?

create bleeding-edge documentation based on javadoc

update your ant-scripts

That seems to be a lot of work just to get a project started

That's right if you do it for the first time, but it's worth the effort! You'll especially notice this when creating medium to large scaled projects.

... but there is Ant already!

Apache Ant is a build tool like make or cmake. However, Apache Maven is a buildmanagement tool.

Glossary

Archetype

An archetype is a template for a project.

http://maven.apache.org/guides/introduction/introduction-to-archetypes.html

Dependency

A dependency is a piece of software which you want use in your project. It can be a library from a repository, another maven project in your workspace or a plain jar.

Repository

A repository is a webserver which contains libraries and source & docs. The most repositories are hosted using Nexus from Sonatype. There are many repos available in the net:

The central maven repository, you'll use this one in 99,5% of your time

http://mvnrepository.com/

What'll be next?

More threads about general android development and how to improve code-quality and stability.

Thanks to:

http://www.apache.org/ - for creating great software since 1999

http://www.sonatype.org/nexus/ - for providing hosting software which we can use

https://code.google.com/p/maven-android-plugin/ - for providing the maven-android-plugin

http://www.eclipse.org/ - for creating the best Java-IDE