Installed it in Windows7 and installed it also in eclipse.
Went to my selenium workspace and created a folder for my first maven project.
Copy and pasted this command
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
com.mycompany.app -> is the group id or package in your java project, you can change this
my-app -> is the project name
This command was pasted in command line in windows inside the maven project.
It will download the needed maven files if it's your first time installing it.
Source Packages in Maven Project
src/main/java - is where you put all your core classes and utilities
src/tset/java - is where you put your test classes like WebDriverTest
They key in Maven project of course is the pom.xml. Without POM you cannot build your maven project. But you have to make sure you right the pom properly. I learned pom.xml by following the tutorial of Software Forum Testin in youtube and below is the sample pom.xml
<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>com.selenium.app</groupId>
<artifactId>myseleniumtests</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myseleniumtests</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testing.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
As you can see, pom.xml is pretty straight forward. If you understand what the file is for you'll understand its content. This file is what is needed by maven to build the project and run it. Above are dependencies I want my build to run with including the plugins.
But I had problem identifying the versions of the plugins I'm using and had several errors in my build. The solution is found here: http://search.maven.org/#browse
You can look for the plugin name and see the version, so you can put it in your pom.xml.
Then if you encounter error, make sure you either run
mvn clean install
or update maven project via eclipse
above did the trick for me after I carelessly deleted my .m2 folder.