maven basics (android & intellij)
DESCRIPTION
A presentation I have given about Maven basic use for Android projectTRANSCRIPT
MavenHussain Mansoor
Folio3 (26 Feb 2014)
Maven defined Declarative Dependencies
External modules
Build Order
Directories
Plug-ins
Build Management
Downloads dependencies and maintains local cache
Support Languages
Primarily Java
C#, Ruby, Scala
IDEs Eclipse, NetBeans, IntelliJ (by default), Jbuilder,
Jdeveloper, MyEclipse…
Build Life cycle process-resources
compile
process-test-resources
test-compile
test
package
install
deploy
<modelVersion>4.0.0</modelVersion>
<groupId>com.project</groupId>
<artifactId>Project</artifactId>
<version>1.1</version>
<packaging>apk</packaging>
<name>Project-Maven</name>
Dependencies
Scope compile, runtime, test, system, and provided
System path Local path, deprecated
groupId
artifactId
Packaging apk, jar, …
Tags defined• A universally unique identifier for a project. It is
normal to use a fully-qualified package name to distinguish it from other projects with a similar name (eg. org.apache.maven, com.project)
The identifier for this artifact that is unique within the group given by the group ID. An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.
E.g: android, mockito-all, junit
The central repository
Online central repository which hosts all the dependencies
Can search from group-id, artifact-id, version
Can also download jars, pom, etc
How to use? POM (pom.xml) file is the main file all the xml
data in it.
Dependent projects (if any) should also have pom
There are 3 major parts: Add dependencies
add dependencies with local path
add dependencies of custom jars (not in maven)
<build>
<plugins> <plugin>
<groupId>com.jayway.maven.plugins.android.generation2
</groupId>
<artifactId>android-maven-plugin</artifactId> <version>3.8.0</version>
<configuration>
<sdk> <platform>8</platform></sdk>
</configuration>
</plugin> </plugins>
</build>
How to add dependencies
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
Local .jar file mvn install:install-file
-DgroupId=com.personagraph
-DartifactId=richinsights
-Dversion=1.4
-Dpackaging=jar -Dfile=libs/AndroidSDK-1.4-SNAPSHOT.jar
cmd mvn clean
mvn test
mvn compile
mvn deploy
Issues with Andriod Maven 3.1.1 is required with Android version
3.8.0
Google-services aren’t supported Create a local jar and include them
References http://maven.apache.org
http://en.wikipedia.org/wiki/Apache_Maven