Source: Safalta
It effectively reduces the number of steps required for the build process instead and turns it into a single step. Download ebooks to gain extensive knowledge about them.Boost your skills by learning:
1) AWS Certified Cloud Practitioner Course
2) Cloud Computing Essentials
Table of Content:
Why Use Maven:
Maven: What Is It? Let's Go Deeper:
How Can Maven Be Installed On Windows?
How Can Maven Be Installed Via The Command Line?
Why Use Maven:
In managing a project's lifecycle, which often entails validation, code creation, compilation, testing, packaging, and other activities, Maven is essential. It's a software development tool that operates in phases as opposed to tasks. It primarily serves to manage a project's life cycle. Maven greatly simplifies the build management procedure because all you have to do is declare the dependency in the pom.xml files—Maven will handle the rest! Several of the main causes Maven is employed include:- It provides a unified system and streamlines the building process.
- It effectively manages duties like dependency management, distribution, compilation, and others.
- It makes things more reusable.
- It streamlines procedures like writing reports, running Junit test cases, adding jar files to the project library, and producing jar/war/ear files during deployment.
- It has a centralized repository for managing jar files.
You probably already know that Maven is indeed a build automation tool used to manage project dependencies throughout the whole project lifecycle. The Apache Software Foundation created Maven, which is primarily used for Java applications. It was initially created to greatly simplify the construction process for the Jakarta Turbine Project, and it is now widely used to make construction procedures simple and standardized. Maven is more accurately described as a project object model (POM)-based software project management solution (POM). It enables the user to establish a preliminary folder structure, carry out compilation and testing, package the finished product, and finally release it. It effectively reduces the number of steps required for the construction process and instead turns it into a single step.
For such a Selenium Maven lesson, you should be aware of the following terms:
- Maven Local repository: The project artifacts are stored in a local repository on the developer's computer. All of the project-dependent jars are loaded into the local repository when a Maven build is run.
- Maven Central Repository: This is the official Maven default repository for all new projects. Maven automatically checks the central repository to download any dependencies that are not available in the local repository.
- Project Object Model: POM XML is used by Maven build to store project data and configuration information. It can be found in each project's root directory.
- Dependency: Any library that a Java project needs to create or run is referred to as a dependency. Examples include the Jar files for Log4j, Apache Poi, Selenium, etc.
- Surefire PlugIn: During the test step of the build lifecycle, one can utiliutilizeSurefire a Plugin to run the unit tests of an application. There are two file types in which a guaranteed report is available: plain text (.txt) and XML (.xml). Use of this plugin is required since it enables Maven to recogrecognizes even when the TestNG or Junit frameworks are being used.
Maven can be set up using the Eclipse IDE or the command line. We'll start by going over the instructions for installing it using the Eclipse IDE.
How Does the Eclipse IDE Install Maven?
The processes involved in installing Maven on Eclipse are rather simple.
Step 1: In Eclipse, click Help from the top menu and choose "Install New Software."
Step 2: Select the Add button on the freshly opened window.
Step 3: Type "Maven" in the name text box and "http://download.eclipse.org/technology/m2e/releases/" in the location text box. The URL where Maven can indeed be downloaded is available here.
Step 4: In the pop-up window, there will be a checkbox. Select it, then click the Next button.
Step 5: Let the window finish processing for a few minutes.
Step 6: Click the Next button while maintaining the default settings.
Step 7: Click Finish after accepting the Terms & Conditions.
Step 8: Hold off on finishing the installation.
Step 9: After the installation is complete, you will be prompted to restart Eclipse. To see the modifications taken into account, select Yes.
How Can Maven Be Installed Via The Command Line?
The steps in this Selenium Maven tutorial to install Maven using the command line are as follows:
Step 1: Download & Install Java:
First, download and install Java. If it hasn't already been done, you must install Java on your computer. You can access this URL to download the most recent version of Java. Please start your computer running and type "cmd" to open the command line to check your system's Java version. To find out the version of Java is installed, type "Java -version" and hit Enter.
Step 2: Set Up Java Environment Variable:
After Java has been installed, configure the Java Environment Variable. To update the Java Environment Variable, access the system settings.
Right-click anywhere on the blank land in This PC and choose Properties.
Setting up Java Environment Variables in Step 2
After Java has been installed, configure the Java Environment Variable. To update the Java Environment Variable, access the system settings.
- Right-click anywhere on the blank land in This PC and choose Properties.
- A new pop-up window will open when you select Advanced System Settings.
- Choose Environment Variables from the pop-up panel by clicking it now.
- Select New from the System variables drop-down menu.
- Enter "JAVA HOME" and the JDK location C: Program FilesJavajdk1.8.0 20 in the variable name and value boxes, respectively, and save the changes.
The freshly formed Java variable is now visible under "System Variables."
- You may download Maven from the following website:https://Maven.apache.org/download.cgi
- Extract it wherever your computer is most convenient for you. It is located at "C:/apache-Maven-3.6.1" for me.
- Identical to how we established the Java Environment Variable in the stages above, you may establish the Maven Environment Variable.
- Fill out the Variable name box with "Maven HOME" and the Variable value box with "C:apache-Maven-3.6.1".
- The freshly formed Maven variable will now be visible under "System Variables."
Update the Path Variable with the Maven installation's "bin" location in order to execute Maven from the command line.
- Through My Computer, access the system properties.
- Go to "Advanced System Settings" by navigating.
- Then, select "Environment Variables."
- Select Edit from the user variables menu.
- PATH and C:apache-Maven-3.6.1bin should be entered in the Variable name and Variable value boxes, respectively.
Your system has now successfully installed Maven. Let's check it now with the Windows command line. Open the command prompt, enter mvn -version, and then click OK. Verify that the results display the edition of Maven that is currently installed on your system. Now that Maven has been installed, you're ready to start generating projects with it. All the necessary libraries can be automatically downloaded from Maven's central repository. As a result, you don't need to keep them locally, which greatly simplifies the task.