Maven — Architecture and Life Cycle

Ruchi Sharma
3 min readJul 27, 2021

In our Automation project, we are using a key tool that makes our framework feasible and manageable. That saviour tool is MAVEN.

Let’s understand what is Maven and how it works.

What is Maven?

In simple terms, Maven is a build automation tool that generates a build for you.

Problem: I am using the following technologies in my project:

  1. JDK 11 ~ Java
  2. Selenium WebDriver
  3. TestNG/JUnit
  4. Apache POI API
  5. Log4J API
  6. JSON/GSON

few other technologies as per the requirement…

There is a hectic process to download JARs for each technology and add them to a project. What if any of the jars got missed? How do I be able to debug which jar is missing out of hundreds of jars?

Doesn’t it sound scary? 😱

Solution: What if I tell you there is no need to beat your brain🤕!! There is an easy solution to this tricky problem.

Let’s have a look at the diagram below:

Maven Architecture

In Maven Repository, all the jar files are available in the form of dependencies. The jars which are required in a project can be taken from Maven Centralised Repository.

Format of a dependency:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>test</scope>
</dependency>

Maven repository is like a library of all open source technologies.

Once you add the dependencies in your project (pom.xml), it will load all jar files and store them in a .m2 folder in your eclipse. This is a hidden folder.

Maven Life Cycle

The Maven life cycle consists of 8 phases. It will compile, test, build and install a project as specified below:

  1. Validate: This step checks if the project structure is correct. It checks whether all the dependencies have been downloaded and are available in the local repository.
  2. Compile: It compiles the source code, converts the .java files to .class and stores the classes in the target/classes folder.
  3. Test: It executes unit tests for the project.
  4. Package: This step packages the compiled code in a distributable format such as JAR/WAR or EAR.
  5. Integration test: Conducts Integration testing for the project by executing Intergration tests.
  6. Verify: This step runs to ensure that the project meets the quality standards.
  7. Install: This step installs the packaged code into the local Maven repository.
  8. Deploy: It copies the packaged code to the remote repository.

Hope this helps you to understand the basics of Maven.

Thanks for reading 🙏🏻 📄

--

--