maven
Maven is a build automation tool for Java-based projects. It is used for managing the build process and its dependencies, including compiling, testing, and packaging the code into a final distribution. Maven provides a standardized way of managing and building projects, making it easier to automate and manage the build process, especially for projects with complex build and dependency requirements. Maven uses a project object model (POM) to manage dependencies, build plugins, and build settings, making it easier to manage and reuse common build components across projects.
What is maven? with the life cycle?
Maven is a project management and comprehension tool that provides developers with a complete build lifecycle framework.POM stands for Project Object Model.
It is a fundamental unit of work in Maven. It is an XML file that resides in the base directory of the project as pom.xml. The POM contains information about the project and various configuration detail used by Maven to build the project(s).
There are three built-in build lifecycles:
- default lifecycle handles project deployment.
- clean lifecycle handles project cleaning.
- site lifecycle handles the creation of the project's site documentation.
What is build meaning in Maven?
Maven is based around the central concept of a build lifecycle. What this means is that the process for building and distributing a particular artifact (project) is clearly defined.For the person building a project, this means that it is only necessary to learn a small set of commands to build any Maven project, and the POM will ensure they get the results they desired.There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's site documentation
What is clean meaning in Maven? Difference in build and clean.
clean is its own build lifecycle phase (which can be thought of as an action or task) in Maven. mvn clean install tells Maven to do the clean phase in each module before running the install phase for each module.
What are maven profiles?
Suppose I have two test different testNG xml files, one for Regression and the other for Smoke testing and I am working on a maven project. Here, for doing so, I will first create two different profiles in POM.xml and then will execute the profile as I want.
POM.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>qaclickacademy</groupId>
<artifactId>Mavenjava</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Mavenjava</name>
<url>http://maven.apache.org</url>
<profiles>
<profile>
<id>Regression</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng_regression.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>Smoke</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng_smoke.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>To execute the required profile: mvn test -pregression, mvn test -psmoke