Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Maven lets you automatically build projects, dependencies, and documentation. This section walks you through setting up Maven with Perfecto. A sample project is available here: https://github.com/PerfectoMobileSA/PerfectoSampleProject

1 | Get started

In this step, you install Java and Maven.

  1. Download and install JDK 8.
  2. Set up the JAVA_HOME environment variable to point to the JDK 8 installation folder.
  3. Download one of the following Maven archives from https://maven.apache.org/download.cgi:
    • Windows: The binary zip file
    • Mac: The source tar.gz file
  4. Specify the path to Maven as follows:

    WindowsMac

    a. Set up the MAVEN_HOME environment variable to point to the JDK 8 installation folder.

    b. Add %MAVEN_HOME%\bin to the PATH environment variable.

    Update your .bash_profile (create this file if it does not exist) with the following:

    export M2_HOME=/Users/<UserName>/<path to maven>
    export PATH=$PATH:$M2_HOME/bin

  5. Launch a command line window and run the following command to verify that the installation was successful:

    Code Block
    mvn –version
Panel

On this page:

Table of Contents
maxLevel2
stylesquare

2 | Create and configure a Maven project

In this step, you create a Maven project and add the repositories, dependencies, and plugins required to run it with Perfecto.

  1. In your IDE, create a Maven project.
  2. Open the pom.xml file and update it as follows. A sample pom.xml file that includes all Perfecto and Smart Reporting dependencies is available here.

    1. Add the following repositories.

      Expand
      titleClick to view repositories
      Code Block
            <repositories>
      		<repository>
      			<id>repo1.perfectomobile.com</id>
      			<name>Perfecto mobile</name>
      			<url>https://repo1.perfectomobile.com/public/repositories/maven</url>
      		</repository>
      		<repository>
      			<id>central</id>
      			<name>Repo1</name>
      			<url>http://repo1.maven.org/maven2</url>
      			<releases>
      				<enabled>true</enabled>
      			</releases>
      			<snapshots>
      				<enabled>false</enabled>
      				<updatePolicy>never</updatePolicy>
      			</snapshots>
      		</repository>
      	</repositories>
      
      	<pluginRepositories>
      		<pluginRepository>
      			<id>central</id>
      			<name>Repo1</name>
      			<url>http://repo1.maven.org/maven2</url>
      			<releases>
      				<enabled>true</enabled>
      			</releases>
      			<snapshots>
      				<enabled>false</enabled>
      				<updatePolicy>never</updatePolicy>
      			</snapshots>
      		</pluginRepository>
      	</pluginRepositories>
    2. Add the following dependencies.

      Expand
      titleClick to view dependencies
      Code Block
      		<dependency>
      			<groupId>com.perfecto.reporting-sdk</groupId>
      			<artifactId>reportium-java</artifactId>
      			<version>RELEASE</version>
      		</dependency>
      		<dependency>
      			<groupId>com.perfecto.reporting-sdk</groupId>
      			<artifactId>reportium-testng</artifactId>
      			<version>RELEASE</version>
      		</dependency>
      		<dependency>
      			<groupId>com.perfectomobile</groupId>
      			<artifactId>pm-webdriver</artifactId>
      			<version>RELEASE</version>
      		</dependency>
      		<dependency>
      			<groupId>com.perfectomobile</groupId>
      			<artifactId>http-client</artifactId>
      			<version>RELEASE</version>
      		</dependency>
      		<dependency>
      			<groupId>dom4j</groupId>
      			<artifactId>dom4j</artifactId>
      			<version>1.6.1</version>
      		</dependency>
      		<dependency>
      			<groupId>jaxen</groupId>
      			<artifactId>jaxen</artifactId>
      			<version>1.1.6</version>
      		</dependency>
      		<dependency>
      			<groupId>org.apache.commons</groupId>
      			<artifactId>commons-lang3</artifactId>
      			<version>3.4</version>
      		</dependency>
      		<dependency>
      			<groupId>commons-io</groupId>
      			<artifactId>commons-io</artifactId>
      			<version>2.4</version>
      		</dependency>
      		<dependency>
      			<groupId>ch.qos.logback</groupId>
      			<artifactId>logback-classic</artifactId>
      			<version>1.1.5</version>
      		</dependency>
      		<dependency>
      			<groupId>ch.qos.logback</groupId>
      			<artifactId>logback-core</artifactId>
      			<version>1.1.5</version>
      		</dependency>
      		<dependency>
      			<groupId>org.slf4j</groupId>
      			<artifactId>slf4j-api</artifactId>
      			<version>1.7.16</version>
      		</dependency>
      		<dependency>
      			<groupId>org.seleniumhq.selenium</groupId>
      			<artifactId>selenium-api</artifactId>
      			<version>3.14.0</version>
      		</dependency>
      		<dependency>
      			<groupId>org.seleniumhq.selenium</groupId>
      			<artifactId>selenium-support</artifactId>
      			<version>3.14.0</version>
      		</dependency>
      		<dependency>
      			<groupId>com.fasterxml.jackson.core</groupId>
      			<artifactId>jackson-core</artifactId>
      			<version>[2.9.10,)</version>
      		</dependency>
      		<dependency>
      			<groupId>com.fasterxml.jackson.core</groupId>
      			<artifactId>jackson-databind</artifactId>
      			<version>[2.9.10,)</version>
      		</dependency>
      		<dependency>
      			<groupId>com.fasterxml.jackson.core</groupId>
      			<artifactId>jackson-annotations</artifactId>
      			<version>[2.9.10,)</version>
      		</dependency>
      		<dependency>
      			<groupId>io.appium</groupId>
      			<artifactId>java-client</artifactId>
      			<version>3.4.1</version>
      		</dependency>
      		<dependency>
      			<groupId>com.google.guava</groupId>
      			<artifactId>guava</artifactId>
      			<version>23.0</version>
      		</dependency>
  3. Add the following plugin to your list of plugins:

    Expand
    titleClick to view plugins
    Code Block
    	    <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <version>2.6</version>
    		<configuration>
    			<encoding>UTF-8</encoding>
    		</configuration>
            </plugin>
  4. To confirm that the dependencies have downloaded properly, execute the Maven goals - clean install.