In our previous article, we have seen how to setup java & maven in both windows & mac os.
In this article, we will see how to create a maven project and some basics of POM.xml.
Maven plugin
For eclipse IDE :
On Eclipse IDE -> Help -> Install new software -> Add… and enter below link to install Maven plugin
Name: Maven
Location: http://download.eclipse.org/technology/m2e/releases
Note: most of the latest versions of eclipse IDE has by default Maven plugin is installed.
For intelliJ IDE :
For the intelliJ, maven plugin comes as default bundle,
in case Maven not installed,
go to File > Settings > Plugins [Windows OS] or go to intelliJ IDEA menu > Preferences > Plugins [Mac OS]
then search for Maven and click on install if it’s not installed.
How to create a Maven project
on Eclipse IDE,
File -> New -> Project
Filter for Maven and select “Maven Project”
Click on Next
Use default workspace or chose your location to the current project > Next
As a starter project, on the Filter: search for “maven-archetype-quickstart” & chose the item as shown below
Click on Next
Enter Group id -> This will identify your project, naming convention as like package name rules.
Enter Artifact id -> project name.
Click on Finish [You are done with creating maven project]
Maven project structure somewhat looks like below
All the base or utility methods should be placed under src/main/java
All the tests should be placed under src/test/java
on intelliJ IDEA
Download the intelliJ IDEA community edition [free & available for both windows / mac OS] from here
Install and open the IDE > Click on New Project > Maven
Project SDK: open the drop down & select the java version
Click on Next
Location: Browse to chose a location
Name: enter the name of project
GroupId: enter the group id
Click on Finish
You will get the maven project as below –
Done with your maven project creation, next update the pom.xml with dependencies and plugins required for selenium or appium.
pom.xml
Sample selenium / appium maven POM.xml with required dependencies can be found here
These dependencies will download all the library files [jar files] under default .m2 folder, If you want to change the default repository location, refer here.
If you are adding new dependencies into pom.xml, then build the project to download the new jar files.
1 Comment