Skip to content

Commit

Permalink
Fix jacoco + code coverage (#151)
Browse files Browse the repository at this point in the history
There was a mix: profile "code-coverage" that was never activated but added coverage to ALL modules, while inject and plexus had their own plugin executions set that ran always.

Limit coverage only to inject + plexus.
  • Loading branch information
cstamas authored Jun 3, 2024
1 parent d3aa661 commit 9a1b55e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
if [ "${{ matrix.isMainBuildEnv }}" = "true" ]; then
echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}" >> $GITHUB_ENV
echo "MVN_ADDITIONAL_OPTS=org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }}" >> $GITHUB_ENV
echo "MVN_ADDITIONAL_OPTS=org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} -Pcode-coverage" >> $GITHUB_ENV
echo "GIT_FETCH_DEPTH=0" >> $GITHUB_ENV # Shallow clones should be disabled for a better relevancy of analysis
else
echo "MVN_ADDITIONAL_OPTS=" >> $GITHUB_ENV
Expand Down
15 changes: 11 additions & 4 deletions org.eclipse.sisu.inject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -478,5 +474,16 @@
</plugins>
</build>
</profile>
<profile>
<id>code-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
18 changes: 13 additions & 5 deletions org.eclipse.sisu.plexus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>code-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
18 changes: 7 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@
<sisu.licenseHeader>https://raw.githubusercontent.com/eclipse-sisu/sisu-project/main/license-header-epl2.txt</sisu.licenseHeader>
<sisu.licenseYear>${project.inceptionYear}-2024</sisu.licenseYear>

<!-- Jacoco and Sonar -->

This comment has been minimized.

Copy link
@kwin

kwin Jun 3, 2024

Contributor

@cstamas Can you elaborate why setting these properties is necessary? The default for Sonar work quite well for me (this is additional stuff to maintain here)

<jacoco.argLine />
<sonar.coverage.jacoco.xmlReportPaths>
${maven.multiModuleProjectDirectory}/org.eclipse.sisu.inject/target/site/jacoco/jacoco.xml,
${maven.multiModuleProjectDirectory}/org.eclipse.sisu.plexus/target/site/jacoco/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>

<!-- Versions -->
<mavenRuntimeVersion>3.2.5</mavenRuntimeVersion>
<mavenBuildVersion>3.6.3</mavenBuildVersion>
Expand Down Expand Up @@ -674,16 +681,5 @@ Bundle-DocURL: http://www.eclipse.org/sisu/
</plugins>
</build>
</profile>
<profile>
<id>code-coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 9a1b55e

Please sign in to comment.