SlideShare a Scribd company logo
Introduction to Maven
● Maven goal and key ideas
● Configuration by conventions
● Project layout
● Build lifecycle
● Dependency management
TOC
Software Development
Software Discrepancy
Software Discrepancy Solution
● shell script
● make (1977)
● Apache Ant (2000)
● MSBuild (2005)
● Apache Maven (2002)
Examples: Build tools
make
Maven Vs. Ant
Holy War
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntProject" basedir="." default="jar">
<property file="nbproject/nbjdk.properties"/>
<property name="user.properties.file"
location="${netbeans.user}/build.
properties"/>
<property file="${user.properties.file}"/>
<import file="nbproject/jdk.xml"/>
<target name="-init" depends="-jdk-init">
<property file="user.build.properties"/>
<property file="build.properties"/>
</target>
<target name="compile" depends="-init" description="Compile main
sources.">
<mkdir dir="${classes.dir}"/>
<depend srcdir="${src.dir}" destdir="${classes.dir}"
cache="build/depcache"
<classpath path="${cp}"/>
</depend>
<javac srcdir="${src.dir}" destdir="${classes.dir}" source="1.5"
debug="${d
<classpath path="${cp}"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" excludes="${jar.excludes}"/>
</copy>
</target>
<target name="jar" depends="compile" description="Build JAR file for
main sour
<jar jarfile="${jar}" compress="true"><!--
manifest="${manifest}" -->
<fileset dir="${classes.dir}"/>
</jar>
</target>
Example: Ant Script
<target name="run" depends="compile" description="Run application.">
<fail unless="main.class">Must set property 'main.class' (e.g. in
build.pro
<java classname="${main.class}" fork="true" failonerror="true">
<classpath path="${run.cp}"/>
<jvmarg value="-ea"/>
</java>
</target>
<target name="compile-tests" depends="compile">
<mkdir dir="${test.classes.dir}"/>
<depend srcdir="${test.dir}" destdir="${test.classes.dir}"
cache="build/test
<classpath path="${test.cp}"/>
</depend>
<javac srcdir="${test.dir}" destdir="${test.classes.dir}" source="1.5"
debug
<classpath path="${test.cp}"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
<copy todir="${test.classes.dir}">
<fileset dir="${test.dir}" excludes="${jar.excludes}"/>
</copy>
</target>
<target name="run-tests" depends="compile-tests" description="Run JUnit
tests."
<mkdir dir="${test.results.dir}"/>
<junit failureproperty="tests.failed" showoutput="true" fork="true">
<batchtest todir="${test.results.dir}">
<fileset dir="${test.dir}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
<classpath path="${test.run.cp}"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
</junit>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x
<modelVersion>4.0.0</modelVersion>
<groupId>com.sperasoft</groupId>
<artifactId>helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
Example: Maven POM
Download: http://maven.apache.org
Version: 2.2.1
Requires: JDK 5+
Nature: Java command line program
Invocation: mvn
Apache Maven
1. Get apache-maven-2.2.1-bin.zip
2. Unpack it to a folder
3. Set M2_HOME env var to the above folder
Install Apache Maven
"A maven (also mavin) is a trusted expert in a
particular field, who seeks to pass knowledge on
to others."
(http://en.wikipedia.org/wiki/Maven)
or
Configuration by Convention
or
Do it right way
Quote
1. Project layout
2. Build lifecycle
Maven Conventions
Simple
Project Layout
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:x
<modelVersion>4.0.0</modelVersion>
<groupId>com.sperasoft</groupId>
<artifactId>helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
pom.xml
Project Layout: Typical
Lifecycles
● Default lifecycle (build)
● Clean lifecycle
● Site lifecycle
Build Lifecycle
Default Lifecycle
compiler
compiler:compile
compiler:testCompile
Example: Compiler Plugin
Lifecycle Bindings: jar
Lifecycle Bindings: pom
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:x
<modelVersion>4.0.0</modelVersion>
<groupId>com.sperasoft</groupId>
<artifactId>helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
pom.xml: packaging
Clean lifecycle bindings
● Dependency
identification
● Getting
dependency
Dependency Management Basis
Maven Coordinates
Repositories
groupId: org.testng
artifactId: testng
version: 5.11
packaging: jar
classifier: jdk15
Maven Coordinates
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x
<modelVersion>4.0.0</modelVersion>
<groupId>com.sperasoft</groupId>
<artifactId>helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
pom.xml: coordinates
Artifact Resolution
Local Repository
Local Repository Population
http://repo1.maven.org/maven2
Number of artifacts (GAV): 313,955
Number of unique artifacts (GA): 38,372
Size of repository: 457,310 MB
Maven Central
Artifact Resolution
1. Choose a library
2. Find Maven coordinates
3. Add <dependency> to POM
4. Use it in your code
Using External Libs
1. Good quality
2. Mature
3. Supported
4. Local expertise
5. Has a reliable source
External Lib Selection
1. Maven Central search
2. Project documentation / site
3. Google
4. Not found? Do not use this crap.
Where to Find Maven Coordinates
http://search.maven.org/
Maven Central Search
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x
...
<dependencies>
...
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
...
</dependencies>
...
</project>
POM: Add Dependency
1. Dependency management explained
2. IDE (Eclipse) integration
3. Testing with Maven
4. Building web applications
5. Serving static content
6. Using binary libs
Maven Talks: Next

More Related Content

PDF
Gradle
Andrii Khaisin
 
ODP
Gradle - time for another build
Igor Khotin
 
PDF
Liferay maven sdk
Mika Koivisto
 
PDF
Jenkinsプラグインの作り方
Kiyotaka Oku
 
KEY
4 maven junit
Honnix Liang
 
PDF
Gradle - time for a new build
Igor Khotin
 
PPT
Java build tool_comparison
Manav Prasad
 
Gradle - time for another build
Igor Khotin
 
Liferay maven sdk
Mika Koivisto
 
Jenkinsプラグインの作り方
Kiyotaka Oku
 
4 maven junit
Honnix Liang
 
Gradle - time for a new build
Igor Khotin
 
Java build tool_comparison
Manav Prasad
 

What's hot (20)

PPTX
Maven
Shraddha
 
PDF
Gradle - Build system evolved
Bhagwat Kumar
 
PDF
Hands on the Gradle
Matthias Käppler
 
PDF
Gradle Introduction
Dmitry Buzdin
 
PDF
Note - Apache Maven Intro
boyw165
 
PPTX
The world of gradle - an introduction for developers
Tricode (part of Dept)
 
PDF
Famo.us - New generation of HTML5 Web Application Framework
Hina Chen
 
PPTX
Maven plugins, properties en profiles: Advanced concepts in Maven
Geert Pante
 
PDF
GlassFish v3 : En Route Java EE 6
Alexis Moussine-Pouchkine
 
PDF
Vue js 大型專案架構
Hina Chen
 
PDF
Vue routing tutorial getting started with vue router
Katy Slemon
 
PPTX
Maven
feng lee
 
PPTX
Introduction to maven
Manos Georgopoulos
 
PPT
Introduction tomaven
Manav Prasad
 
PDF
Gradle - the Enterprise Automation Tool
Izzet Mustafaiev
 
PDF
VueJS Introduction
David Ličen
 
PPTX
Maven
Khan625
 
PDF
maven
akd11
 
PDF
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
PPTX
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Maven
Shraddha
 
Gradle - Build system evolved
Bhagwat Kumar
 
Hands on the Gradle
Matthias Käppler
 
Gradle Introduction
Dmitry Buzdin
 
Note - Apache Maven Intro
boyw165
 
The world of gradle - an introduction for developers
Tricode (part of Dept)
 
Famo.us - New generation of HTML5 Web Application Framework
Hina Chen
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Geert Pante
 
GlassFish v3 : En Route Java EE 6
Alexis Moussine-Pouchkine
 
Vue js 大型專案架構
Hina Chen
 
Vue routing tutorial getting started with vue router
Katy Slemon
 
Maven
feng lee
 
Introduction to maven
Manos Georgopoulos
 
Introduction tomaven
Manav Prasad
 
Gradle - the Enterprise Automation Tool
Izzet Mustafaiev
 
VueJS Introduction
David Ličen
 
Maven
Khan625
 
maven
akd11
 
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Ad

Similar to Introduction to Maven (20)

PPTX
Maven Basics - Explained
Smita Prasad
 
PPT
Mavenppt
Surekha Achanta
 
PDF
Java Builds with Maven and Ant
David Noble
 
PDF
Hands On with Maven
Sid Anand
 
PPTX
Maven and versioning
KadarkaraiSelvam
 
PPTX
Maven basics
Vijay Krishnan Ramaswamy
 
PPTX
Learning Maven by Example
Hsi-Kai Wang
 
PPTX
Java build tools
Sujit Kumar
 
PPT
Maven 2 features
Angel Ruiz
 
PPTX
Maven
Chas Honton
 
PPTX
Introduction to Maven for beginners and DevOps
SISTechnologies
 
PPT
Maven introduction in Mule
Shahid Shaik
 
PPTX
Ci jenkins maven svn
Ankur Goyal
 
PPT
Maven
darshanvartak
 
PPT
Maven in Mule
Anand kalla
 
PDF
Java, Eclipse, Maven & JSF tutorial
Raghavan Mohan
 
PPT
Maven
Sunil Komarapu
 
PPTX
Apache Maven basics
Volodymyr Ostapiv
 
PPTX
Maven
Emprovise
 
Maven Basics - Explained
Smita Prasad
 
Mavenppt
Surekha Achanta
 
Java Builds with Maven and Ant
David Noble
 
Hands On with Maven
Sid Anand
 
Maven and versioning
KadarkaraiSelvam
 
Learning Maven by Example
Hsi-Kai Wang
 
Java build tools
Sujit Kumar
 
Maven 2 features
Angel Ruiz
 
Introduction to Maven for beginners and DevOps
SISTechnologies
 
Maven introduction in Mule
Shahid Shaik
 
Ci jenkins maven svn
Ankur Goyal
 
Maven in Mule
Anand kalla
 
Java, Eclipse, Maven & JSF tutorial
Raghavan Mohan
 
Apache Maven basics
Volodymyr Ostapiv
 
Maven
Emprovise
 
Ad

More from Sperasoft (20)

PDF
особенности работы с Locomotion в Unreal Engine 4
Sperasoft
 
PDF
концепт и архитектура геймплея в Creach: The Depleted World
Sperasoft
 
PPTX
Опыт разработки VR игры для UE4
Sperasoft
 
PPTX
Организация работы с UE4 в команде до 20 человек
Sperasoft
 
PPTX
Gameplay Tags
Sperasoft
 
PDF
Data Driven Gameplay in UE4
Sperasoft
 
PPTX
Code and Memory Optimisation Tricks
Sperasoft
 
PPTX
The theory of relational databases
Sperasoft
 
PPTX
Automated layout testing using Galen Framework
Sperasoft
 
PDF
Sperasoft talks: Android Security Threats
Sperasoft
 
PDF
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft
 
PDF
Sperasoft‬ talks j point 2015
Sperasoft
 
PDF
Effective Мeetings
Sperasoft
 
PDF
Unreal Engine 4 Introduction
Sperasoft
 
PDF
JIRA Development
Sperasoft
 
PDF
Introduction to Elasticsearch
Sperasoft
 
PDF
MOBILE DEVELOPMENT with HTML, CSS and JS
Sperasoft
 
PDF
Quick Intro Into Kanban
Sperasoft
 
PDF
ECMAScript 6 Review
Sperasoft
 
PDF
Console Development in 15 minutes
Sperasoft
 
особенности работы с Locomotion в Unreal Engine 4
Sperasoft
 
концепт и архитектура геймплея в Creach: The Depleted World
Sperasoft
 
Опыт разработки VR игры для UE4
Sperasoft
 
Организация работы с UE4 в команде до 20 человек
Sperasoft
 
Gameplay Tags
Sperasoft
 
Data Driven Gameplay in UE4
Sperasoft
 
Code and Memory Optimisation Tricks
Sperasoft
 
The theory of relational databases
Sperasoft
 
Automated layout testing using Galen Framework
Sperasoft
 
Sperasoft talks: Android Security Threats
Sperasoft
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft
 
Sperasoft‬ talks j point 2015
Sperasoft
 
Effective Мeetings
Sperasoft
 
Unreal Engine 4 Introduction
Sperasoft
 
JIRA Development
Sperasoft
 
Introduction to Elasticsearch
Sperasoft
 
MOBILE DEVELOPMENT with HTML, CSS and JS
Sperasoft
 
Quick Intro Into Kanban
Sperasoft
 
ECMAScript 6 Review
Sperasoft
 
Console Development in 15 minutes
Sperasoft
 

Recently uploaded (20)

PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 

Introduction to Maven