2. WHAT IS MAVEN?
• Maven is a build tool and based on a software project management
tool.
• Development team can automate the project's build infrastructure in
almost no time as Maven uses a standard directory layout and a default
build lifecycle.
• Maven can set-up the way to work as per standards in a very short
time.
• The project setups are simple and reusable, it makes life of developer
easy while creating reports, checks, build and testing automation
setups.
3. OBJECTIVES OF MAVEN
• It is reusable and maintainable.
• It making build process easy.
• It gives quality project information.
• Transparent migration to new features.
• Guideline for best development practices.
5. ADVANTAGE OF MAVEN
• It is an easy to start to the project in different environment.
• It is easy to build your project to a jar, as per requirement.
• Easily add new dependencies by writing the dependency code in the
pom file.
6. DISADVANTAGE OF MAVEN
• Maven code for an existing dependency is not available,
then cannot add that dependency.
• Maven installation along with plugin is must.
7. DIFFERENCE BETWEEN ANT VS MAVEN?
Maven
• Maven is a project management tool.
• It has a convention to compiled code,
place source code.
• It is declarative, everything define in
the pom.xml file.
• There is a life cycle in Maven and it is
a Framework.
• The Maven plugins are reusable and it
is more preferred than Ant.
Ant
• Ant is a build tool.
• It doesn't have formal conventions.
• It is procedural, to give proper
information about what to do and
when to do through code.
• There is a no life cycle in Ant and it is
a toolbox.
• The ant scripts are not reusable and it
is not so preferred than Maven.
18. MAVEN REPOSITORY
• A Maven repository is a directory of packaged JAR file with
pom.xml file.
• It searches for dependencies in the repositories.
• There are three types of repository.
• Local Repository
• Central Repository
• Remote Repository
20. LOCAL REPOSITORY
• Maven local repository is a local folder on a system.
• It is created by the maven when you run any maven command.
• It Stores all dependency library jars, plugin jars, etc on your
development machine.
• When Maven downloads the dependency jars it stores the jar files in
the local Maven repository.
• Maven creates a local repository under %USER_HOME% Directory.
21. CENTRAL REPOSITORY
• Maven central repository is repository managed by Maven community.
• It contains a large number of commonly used libraries And can publish own
libraries to Maven central repository as well.
• When maven cannot find any dependency jar file on a local repository, it starts
searching on a central repository on a URL: http://repo1.maven.org/maven2/.
• Search a jar file in central repository.
22. REMOTE REPOSITORY
• Sometime need to set up a Maven repository inside a company or a
project development team to host own libraries.
• The company maintained repository is outside developer's machine
is called remote repository.
23. BUILD LIFE CYCLE
• It is a well defined sequences of phases.
• It is in order which goals are to be executed.
• Each phases consist of sequence of goals.
• If one build life cycle is executed, all build phases will
executed.
24. • Build plug in:
• Add plugin to he pom file when it need to perform a
certain a set of project which are not covered by
maven build phases and goals.
• Every task is done through plug in
• It gives a set of goals.
• Plug in is mentioned in pom.xml file using plugin
elements.
25. PROJECT OBJECT MODEL (POM)
• POM is an Project Object Model and it is fundamental unit of work in Maven.
• POM is stored in xml file.
• It also has goals and plugin
• It contains information of project and configuration information for the maven to
build the project such as dependencies, build directory, source directory, test
source directory, plugin, goals etc.
• Maven reads the pom.xml file, then executes the goal.
26. STRUCTURE OF MAVEN POM.XML FILE
• Project
• It is the root element of pom.xml file.
• Model version
• It is the sub element of project.
• It specifies the model Version.
• It should be set to 4.0.0.
• Group id
• It is the sub element of project.
• It specifies the id for the project group.
27. • Artifact id
• It specifies the id for the artifact.
• Artifact is something that is either produced or used by a project.
• Examples JARs, source and binary distributions, and WARs.
• Version
• It specifies the version of the artifact under given group.
• Packaging
• Defines packaging type such as jar, war etc.
• Name
• Defines name of the maven project.
28. • Dependies
• Defines dependencies for this project.
• Dependency
• Defines a dependency. It is used inside dependencies.
• Scope
• Defines scope for this maven project. It can be compile, provided,
runtime, test and system.
29. JAVA PROGRAM USING MAVEN
package maven.selenium.testng;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class DemoClass {
@Test
public void test() throws InterruptedException
{
System.setProperty("webdriver.chrome.driver","C:UsersArvind PhulareDesktopchromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "<a href="http://newtours.demoaut.com/">http://newtours.demoaut.com/</a>";
String expectedTitle = "Welcome: Mercury Tours";
31. HOW TO INSTALL MAVEN IN ECLIPSE
• Open Eclipse ID and click
help and go to install new
software.
• Then opened, click on
the Add button to add a new
repository.
32. • Fill the name and location
information Add repository
box
• Then click ok.
33. • After pending finished,
select all and click next.
• Accept the terms of the
license agreement and
click Finish
• At the end of the
installation, restart your
Eclipse. Click Yes to
perform the restart.