QA‎ > ‎

maven

Maven

Apache Maven is most popular tool to build Java Application.  Maven will build the project by reading contents from POM.xml. POM stands for Project Object Model. This file will contain typical information related to artifacts, dependencies, configuration etc. Since from version 2, it is renamed as POM.xml, earlier version its name was project.xml. 

All POM.xml file will extends from Super POM, which will have basic information and definitions. Each POM.xml file should contain following xml tags...
  • project root
  • model version
  • groupId
  • artifactId
  • version
Example: 

<modelVersion>4.0.0</modelVersion>
<groupId>com.pavan.jbehave.demo</groupId>
<artifactId>jbehave-demo</artifactId>
<version>1.0-SNAPSHOT</version>

Dependencies


Here in this section , user can specify all dependency artifacts that are required to build the project. 
Example: 
<dependencies>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.7</version>
</dependency>
<!-- dependency for JBehave  -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.25.0</version>
</dependency>
<!-- dependency for selenium test executions -->
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
</dependency>
</dependencies>

In the above example, user included dependency files like jbehave-core, selenium-java and operadriver as they are required to build the project. By providing this information, Maven will download dependency artifacts and stores it to Maven Home.

Build:


Build tag will contain all the information related to build. example:
<build>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>${basedir}/src/main/java</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<executions>
<execution>
<id>run-stories-as-embeddables</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>**/CalcStories.java</include>
</includes>
<ignoreFailureInStories>true</ignoreFailureInStories>
<ignoreFailureInView>false</ignoreFailureInView>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>



In the above example, user included jbehave-maven-plugin to run JBehave stories.
Comments