Misc. Coverage Fixes

- Collect coverage data for hyracks modules
- Generate aggregate coverage report for SonarQube

Change-Id: Ib44d8ed4fe81d2e26380e1bf6e02b7458910be0a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/841
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>
diff --git a/hyracks-fullstack/pom.xml b/hyracks-fullstack/pom.xml
index f2e0eea..54e7f34 100644
--- a/hyracks-fullstack/pom.xml
+++ b/hyracks-fullstack/pom.xml
@@ -45,6 +45,8 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <jdk.version>1.8</jdk.version>
         <jvm.extraargs/>
+        <sonar.jacoco.reportPath>${env.PWD}/target/jacoco-merged.exec</sonar.jacoco.reportPath>
+
         <!-- Definition of tests in various categories which may be excluded -->
         <hanging.pregelix.tests>**/pregelix/**/FailureRecovery*.java</hanging.pregelix.tests>
         <hivesterix.perf.tests>**/hivesterix/perf/PerfTestSuite.java</hivesterix.perf.tests>
@@ -55,6 +57,7 @@
         <hadoop.version>2.2.0</hadoop.version>
         <junit.version>4.8.1</junit.version>
         <commons.io.version>2.4</commons.io.version>
+        <jacoco.version>0.7.6.201602180812</jacoco.version>
     </properties>
     <dependencyManagement>
         <dependencies>
@@ -218,11 +221,14 @@
 	  <failIfNoTests>false</failIfNoTests>
 	  <forkCount>1</forkCount>
           <reuseForks>false</reuseForks>
-	  <argLine>-enableassertions -Xmx2048m
-	  -Dfile.encoding=UTF-8
-	  -Djava.util.logging.config.file=${user.home}/logging.properties
-	  -Xdebug
-	  -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n</argLine>
+    <argLine>
+      -enableassertions -Xmx2048m
+      -Dfile.encoding=UTF-8
+      -Djava.util.logging.config.file=${user.home}/logging.properties
+      -Xdebug
+      -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
+      ${coverageArgLine}
+    </argLine>
 	  <includes>
 	    <include>${global.test.includes},${test.includes}</include>
 	  </includes>
@@ -385,6 +391,57 @@
       </build>
     </profile>
     <profile>
+      <id>coverage</id>
+      <activation>
+        <property>
+          <name>coverage</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.jacoco</groupId>
+            <artifactId>jacoco-maven-plugin</artifactId>
+            <version>${jacoco.version}</version>
+            <executions>
+              <execution>
+                <id>default-prepare-agent</id>
+                <goals>
+                  <goal>prepare-agent</goal>
+                </goals>
+                <configuration>
+                  <propertyName>coverageArgLine</propertyName>
+                </configuration>
+              </execution>
+              <execution>
+                <id>default-prepare-agent-integration</id>
+                <goals>
+                  <goal>prepare-agent-integration</goal>
+                </goals>
+                <configuration>
+                  <propertyName>coverageArgLine</propertyName>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+      <properties>
+        <coverage/>
+      </properties>
+    </profile>
+    <profile>
+      <id>no-coverage</id>
+      <activation>
+        <property>
+          <name>!coverage</name>
+        </property>
+      </activation>
+      <properties>
+        <coverageArgLine/>
+      </properties>
+    </profile>
+    <profile>
         <id>java8</id>
         <activation>
             <jdk>1.8</jdk>