chore: add sonarcloud reporting for aggregate test coverage in gax, api-common and showcase  (#1482)

* chore: add sonarcloud reporting for aggregate test coverage in gax, api-common and showcase

diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml
index 57f44fb..07c4a18 100644
--- a/.github/workflows/sonar.yaml
+++ b/.github/workflows/sonar.yaml
@@ -1,4 +1,6 @@
 name: SonarCloud Build
+env:
+  SHOWCASE_VERSION: 0.25.0
 on:
   push:
     branches:
@@ -41,3 +43,39 @@
               -Dsonar.organization=googleapis \
               -Dsonar.host.url=https://sonarcloud.io
 
+      - name: Install showcase server
+        run: |
+          sudo mkdir -p /usr/src/showcase
+          sudo chown -R ${USER} /usr/src/
+          curl --location https://github.com/googleapis/gapic-showcase/releases/download/v${SHOWCASE_VERSION}/gapic-showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz --output /usr/src/showcase/showcase-${SHOWCASE_VERSION}-linux-amd64.tar.gz
+          cd /usr/src/showcase/
+          tar -xf showcase-*
+          ./gapic-showcase run &
+          cd -
+      - name: Build and analyze Showcase Integration Tests Coverage
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+        run: |
+          mvn -B clean verify -Dcheckstyle.skip \
+              -DskipUnitTests \
+              -Penable-integration-tests \
+              -DenableTestCoverage \
+              org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
+              -Dsonar.projectKey=googleapis_gapic-generator-java_integration_tests \
+              -Dsonar.organization=googleapis \
+              -Dsonar.host.url=https://sonarcloud.io \
+              -Dsonar.projectName=java_showcase_integration_tests
+      - name: Build and analyze Showcase Unit Tests Coverage
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+        run: |
+          mvn -B clean test -Dcheckstyle.skip \
+              -DenableTestCoverage \
+              org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
+              -Dsonar.projectKey=googleapis_gapic-generator-java_unit_tests \
+              -Dsonar.organization=googleapis \
+              -Dsonar.host.url=https://sonarcloud.io \
+              -Dsonar.projectName=java_showcase_unit_tests
+
diff --git a/coverage-report/README.md b/coverage-report/README.md
index 9326c42..efd70b2 100644
--- a/coverage-report/README.md
+++ b/coverage-report/README.md
@@ -1,23 +1,22 @@
 ## Coverage Report
 
-This module gathers aggregated jacoco test coverage metrics across the `gax-java` and `showcase` modules. The purpose of
-the metrics is to provide insights into how much of GAX code is being exercised by showcase and GAX tests and where 
-(unit tests versus integration tests). They will also provide information on any change in coverage observed
-as showcase tests continue to be added to the repository.
+This module gathers aggregated jacoco test coverage metrics across the `api-common`, `gax-java` and `showcase` modules. The purpose of
+the metrics is to provide insights into how much of api-common and GAX code is being exercised by showcase, GAX and api-common tests and where 
+(unit tests versus integration tests). They will also assist with tracking any changes in coverage as showcase tests continue to be added to the repository.
 
 ### Unit Test Coverage
-In order to view aggregate unit test coverage of GAX in both `gax-java` and `showcase`:
+In order to view aggregate unit test coverage of api-common and GAX in `api-common`, `gax-java` and `showcase`:
 
 1. At the root of the repository, run `mvn clean test -DenableTestCoverage`.
 2. The metrics can be found at `gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html`
 
-![Screenshot 2023-03-03 at 6 32 50 PM](https://user-images.githubusercontent.com/66699525/222854612-787b4dde-f9a3-469a-8227-8f46dc0a4a20.png)
+![Screenshot 2023-03-21 at 12 25 41 PM](https://user-images.githubusercontent.com/66699525/226675190-5225e778-99d4-44d0-8177-29d48d1c35ee.png)
 
 ### Integration Test Coverage
 
-In order to view aggregate integration test coverage of GAX in both `gax-java` and `showcase`:
+In order to view aggregate integration test coverage of api-common and GAX in `api-common`, `gax-java` and `showcase`:
 
 1. At the root of the repository, run `mvn clean verify -DskipUnitTests -DenableTestCoverage -Penable-integration-tests`.
 2. The metrics can be found at `gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html`
 
-![Screenshot 2023-03-03 at 6 36 26 PM](https://user-images.githubusercontent.com/66699525/222854973-f8a96f01-abc1-4e6b-9ab8-99b5e50dec6a.png)
\ No newline at end of file
+![Screenshot 2023-03-21 at 12 26 26 PM](https://user-images.githubusercontent.com/66699525/226675461-97a1c4b5-a90f-470d-b0c8-51e63a35a548.png)
diff --git a/coverage-report/pom.xml b/coverage-report/pom.xml
index 7851a2a..758cc38 100644
--- a/coverage-report/pom.xml
+++ b/coverage-report/pom.xml
@@ -32,17 +32,22 @@
             <dependency>
                 <groupId>com.google.api</groupId>
                 <artifactId>gax</artifactId>
-                <version>2.23.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
+                <version>2.23.4-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
             </dependency>
             <dependency>
                 <groupId>com.google.api</groupId>
                 <artifactId>gax-grpc</artifactId>
-                <version>2.23.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
+                <version>2.23.4-SNAPSHOT</version> <!-- {x-version-update:gax-grpc:current} -->
             </dependency>
             <dependency>
                 <groupId>com.google.api</groupId>
                 <artifactId>gax-httpjson</artifactId>
-                <version>0.108.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
+                <version>0.108.4-SNAPSHOT</version> <!-- {x-version-update:gax-httpjson:current} -->
+            </dependency>
+            <dependency>
+                <groupId>com.google.api</groupId>
+                <artifactId>api-common</artifactId> <!-- {x-version-update:api-common:current} -->
+                <version>2.6.4-SNAPSHOT</version>
             </dependency>
         </dependencies>
 
diff --git a/gapic-generator-java-pom-parent/pom.xml b/gapic-generator-java-pom-parent/pom.xml
index b399687..9421307 100644
--- a/gapic-generator-java-pom-parent/pom.xml
+++ b/gapic-generator-java-pom-parent/pom.xml
@@ -177,7 +177,6 @@
       </build>
     </profile>
   </profiles>
-  
   <repositories>
     <repository>
       <id>google-maven-central-copy</id>
diff --git a/gapic-generator-java/pom.xml b/gapic-generator-java/pom.xml
index 1369a3a..be17f1f 100644
--- a/gapic-generator-java/pom.xml
+++ b/gapic-generator-java/pom.xml
@@ -76,6 +76,19 @@
         </plugins>
       </build>
     </profile>
+
+    <!-- Skip gapic-generator-java when analyzing showcase test coverage on SonarCloud   -->
+    <profile>
+      <id>showcase-sonar-analysis</id>
+      <activation>
+        <property>
+          <name>enableTestCoverage</name>
+        </property>
+      </activation>
+      <properties>
+        <sonar.skip>true</sonar.skip>
+      </properties>
+    </profile>
   </profiles>
 
   <build>
diff --git a/java-common-protos/pom.xml b/java-common-protos/pom.xml
index 4b4a866..e9af505 100644
--- a/java-common-protos/pom.xml
+++ b/java-common-protos/pom.xml
@@ -174,4 +174,19 @@
       </plugin>
     </plugins>
   </reporting>
+
+  <!-- Skip google-common-protos when analyzing showcase test coverage on SonarCloud   -->
+  <profiles>
+    <profile>
+      <id>showcase-sonar-analysis</id>
+      <activation>
+        <property>
+          <name>enableTestCoverage</name>
+        </property>
+      </activation>
+      <properties>
+        <sonar.skip>true</sonar.skip>
+      </properties>
+    </profile>
+  </profiles>
 </project>
diff --git a/java-iam/pom.xml b/java-iam/pom.xml
index ef5dcab..3ad465f 100644
--- a/java-iam/pom.xml
+++ b/java-iam/pom.xml
@@ -218,4 +218,19 @@
       </plugin>
     </plugins>
   </reporting>
+
+  <!-- Skip java-iam when analyzing showcase test coverage on SonarCloud   -->
+  <profiles>
+    <profile>
+      <id>showcase-sonar-analysis</id>
+      <activation>
+        <property>
+          <name>enableTestCoverage</name>
+        </property>
+      </activation>
+      <properties>
+        <sonar.skip>true</sonar.skip>
+      </properties>
+    </profile>
+  </profiles>
 </project>
diff --git a/pom.xml b/pom.xml
index fd48121..a022c29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,6 +91,9 @@
         <module>showcase</module>
         <module>coverage-report</module>
       </modules>
+      <properties>
+        <sonar.coverage.jacoco.xmlReportPaths>${maven.multiModuleProjectDirectory}/coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
+      </properties>
     </profile>
   </profiles>