In this Tutorial, we will learn the basics of Maven includes Maven introduction, Advantages of Maven, Maven Life cycle and Important terminology.
What is Maven?
Maven is a flexible build management tool for Java projects, which means, Maven helps to compile and build your selenium java project.
How to leverage maven capabilities in Selenium Projects?
- Maven helps to compile and build your selenium project while executing from Jenkins
- Maven uses POM.xml configuration file which helps to keep all selenium dependencies in POM.xml, therefore, this process eliminates to download selenium JARs and add to Eclipse build path manually.
- Upgrade Selenium to Latest versions – Maven make this process very easy as you just need to replace the new version (For example, currently you’re using selenium 2.5, if you want to upgrade to latest version, you just need to replace with 3.14) in POM.xml file
- Maven downloads all JAR files to it’s local repository called .m2, whenever you modify the POM.xml, First, maven will check the JAR files are available in .m2 local repository, if unavailable then Maven will automatically download the latest JARs from Maven central repository and keep it in .m2 local repository.
- Selenium integration with Jenkins -Maven plays prominent role in terms of compiling and building the selenium project resided in GIT so that Jenkins always executes the latest build
Do we really need Maven to execute selenium project from jenkins (Continuous Integration Tool)?
No, you can still integrate normal Java project to Jenkins
Maven Key Life cycle Phases
Compile – Compiles the project source code, which means, Maven converts .java files into .class files, For example, if maven found, syntax or compilation errors in the projects, it will halt the execution, thus you need to fix the errors before initiate the execution.
Package the code – take the compiled code and converts into a JAR file
Install – Install the project artifacts into local .m2 repository and ensure that POM.xml and .m2 in sync, if not, maven will download the latest libraries into .m2 repository.
- Group Id – This is an unique identifier of organization or group that created a project.
- Artifact Id – This is an unique name of primary artifact is being generated by your project
- Version – Indicate that version of the artifact generated by your project
.m2 Local repository Location – C:\Users\—-\.m2
Important to note that you don’t need to install maven as ‘Install New Software‘ from Eclipse any longer because latest Eclipse IDE comes with Maven plug-in.
To download Maven for Windows Click Here
To create maven project in Eclipse IDE Click Here
To learn more about Maven, Please Click Here
For any questions, Please leave a comment here or drop an email to ‘email@example.com‘