0% found this document useful (0 votes)
46 views17 pages

Maven DP

This document provides an introduction to Maven, a build automation and project management tool. It discusses what Maven is used for, its core concepts like the build lifecycle, phases and goals. The document explains Maven's standard project structure and the pom.xml file, which contains project configuration. It demonstrates some common Maven goals and provides a task for students to create their own Maven project.

Uploaded by

Mmk Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views17 pages

Maven DP

This document provides an introduction to Maven, a build automation and project management tool. It discusses what Maven is used for, its core concepts like the build lifecycle, phases and goals. The document explains Maven's standard project structure and the pom.xml file, which contains project configuration. It demonstrates some common Maven goals and provides a task for students to create their own Maven project.

Uploaded by

Mmk Reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

INTRODUCTION

TO
MAVEN

DURGA ADIMULAM

September 8,
September 8, 2020
2020
PURPOSE OF THE SESSION

The purpose of this Maven session is to make you understand how Maven
works. Therefore this tutorial focuses on the core concepts of Maven.
Once you understand the core concepts, it is much easier to lookup detailed
information in the Maven documentation, or search for it on the internet.
Common Problems and Activities

• Multiple Jars
• Dependencies and Versions
• Project Structure
• Building, Publishing and deploying
WHAT IS MAVEN?

Maven is a powerful build automation and project management tool that


provides developers a complete build lifecycle framework.

A build tool is a tool that automates everything related to building the


software project.

Building a software project typically includes one or more of these activities:

• Generating source code (if auto-generated code is used in the project).


• Generating documentation from the source code.
• Compiling source code.
• Packaging compiled code into JAR files or ZIP files.
Maven Build Lifecycle

A Maven Build follows a lifecycle.

• Default lifecycle
 generate-sources/generate-resources
 Compile
 Test
 Package
 Install
 Deploy
• Clean lifecycle
• Site lifecycle
Maven Build Lifecycle Phases

• validate - validate the project is correct and all necessary information is available
• compile - compile the source code of the project
• test - test the compiled source code using a suitable unit testing framework. These tests should
not require the code be packaged or deployed
• package - take the compiled code and package it in its distributable format, such as a JAR.
• verify - run any checks on results of integration tests to ensure quality criteria are met
• install - install the package into the local repository, for use as a dependency in other projects
locally
• deploy - done in the build environment, copies the final package to the remote repository for
sharing with other developers and projects.
Maven Archetype

• Maven standard Directory Structure


• Pom.xml
Maven Standard Directory Structure
POM.xml

• A Project Object Model or POM is the fundamental unit of work in


Maven. It is an XML file that contains information about the project and
configuration details used by Maven to build the project.

• When executing a task or goal, Maven looks for the POM in the current
directory. It reads the POM, gets the needed configuration information,
then executes the goal.
POM.xml

Minimal POM
The minimum requirement for a POM are the following:
• project root
• modelVersion - should be set to 4.0.0
• groupId - the id of the project's group.
• artifactId - the id of the artifact (project)
• version - the version of the artifact under the specified group
How Maven uses POM.xml
Example Maven Goals

To Invoke a Maven build we need to set lifecycle “goal”

• mvn install
- Invokes generate* and compile, test, package, integration-test, install
• mvn clean
- Invokes just clean
• mvn clean compile
- Cleans old builds and execute generate* and compile
• mvn compile install
- Invokes generate*, compile, test, integration-test, package, install
• mvn test clean
- Invokes generate*, compile, test then cleans the build
DEMO of Maven

• Installation
• Setting environment variable – M2_HOME
• Setting PATH variable
• Creating the Project using Maven
• Compiling the source code using Maven
• Packaging the source code using Maven
• Running the sample code
Home Task

• Create a sample maven project from command prompt with quick start
archetype
• Also use Maven life cycle to execute and verify the files/folders generated.
Resources

• https://maven.apache.org/

• https://maven.apache.org/maven-features.html

• https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
Q&A
THANK YOU
DURGA ADIMULAM

You might also like