Add JaCoCo for code coverage reports

It looks that emma reports are not perfect.
Some classes are missed in the report.

JaCoCo does the job. And you can define rules
to break the build if the coverage to low.
Currently the limit is 40% for the whole project.
This is what Volley currently has.

To get the report call (one of them):
$ mvn clean verify
$ mvn clean install

You find the report in target\jacoco-report

Change-Id: I7f5e2d5de0ffaa779148dfb0e239e8e95a1055e0
Signed-off-by: Ralph Bergmann <ralph@the4thfloor.eu>
diff --git a/pom.xml b/pom.xml
index 47252cb..c745a5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,14 +62,104 @@
             <target>${java.version}</target>
           </configuration>
         </plugin>
-
-	<plugin>
-          <groupId>org.codehaus.mojo</groupId>
-          <artifactId>emma-maven-plugin</artifactId>
-          <version>1.0-alpha-3</version>
-        </plugin>
-
       </plugins>
     </pluginManagement>
   </build>
+
+  <profiles>
+    <profile>
+      <id>debug</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+        <property>
+          <name>performDebugBuild</name>
+          <value>true</value>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <version>2.18.1</version>
+            <executions>
+              <execution>
+                <id>default-test</id>
+                <configuration>
+                  <argLine>${surefireArgLine}</argLine>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.jacoco</groupId>
+            <artifactId>jacoco-maven-plugin</artifactId>
+            <!-- don't upgrade the version. newer versions generate different results
+             see https://github.com/jacoco/jacoco/issues/286 -->
+            <version>0.7.2.201409121644</version>
+            <executions>
+              <execution>
+                <id>pre-unit-test</id>
+                <goals>
+                  <goal>prepare-agent</goal>
+                </goals>
+                <configuration>
+                  <destFile>${project.build.directory}/surefire-reports/jacoco-ut.exec</destFile>
+                  <propertyName>surefireArgLine</propertyName>
+                </configuration>
+              </execution>
+              <execution>
+                <id>jacoco-report</id>
+                <phase>post-integration-test</phase>
+                <goals>
+                  <goal>report</goal>
+                  <goal>check</goal>
+                </goals>
+                <configuration>
+                  <dataFile>${project.build.directory}/surefire-reports/jacoco-ut.exec</dataFile>
+                  <outputDirectory>${project.build.directory}/jacoco-report</outputDirectory>
+                  <rules>
+                    <rule>
+                      <element>BUNDLE</element>
+                      <limits>
+                        <limit>
+                          <counter>INSTRUCTION</counter>
+                          <value>COVEREDRATIO</value>
+                          <minimum>0.40</minimum>
+                        </limit>
+                        <!-- enable this if you want that the build breaks if there is a class without a test -->
+                        <!--
+                        <limit>
+                          <counter>CLASS</counter>
+                          <value>MISSEDCOUNT</value>
+                          <maximum>0</maximum>
+                        </limit>
+                        -->
+                      </limits>
+                    </rule>
+                    <!-- enable this if you want a limit for each java class -->
+                    <!--
+                    <rule>
+                      <element>CLASS</element>
+                      <excludes>
+                        <exclude>*Test</exclude>
+                      </excludes>
+                      <limits>
+                        <limit>
+                          <counter>LINE</counter>
+                          <value>COVEREDRATIO</value>
+                          <minimum>0.10</minimum>
+                        </limit>
+                      </limits>
+                    </rule>
+                    -->
+                  </rules>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 </project>