You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2024/12/21 15:17:04 UTC

(maven-apache-parent) 01/01: Manage jacoco-maven-plugin

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/jacoco-profile
in repository https://gitbox.apache.org/repos/asf/maven-apache-parent.git

commit c5059a16abc3499edf56d963994f267fe0079614
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sat Dec 21 16:16:55 2024 +0100

    Manage jacoco-maven-plugin
    
    Add dedicated profile "coverage" to generate separate reports for both
    UTs and ITs.
    
    This closes #283
---
 pom.xml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 58 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 490f2bd..4b4ad3c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,6 +101,8 @@ under the License.
     <maven.compiler.target>8</maven.compiler.target><!-- use version numbers without the "1." prefix (supported since javac 5) -->
     <surefire.version>3.5.2</surefire.version><!-- for surefire, failsafe and surefire-report -->
     <assembly.tarLongFileMode>posix</assembly.tarLongFileMode>
+    <jacoco.append.ut.file>false</jacoco.append.ut.file><!-- set to true to always append for unit test coverage, overwrites default due to  https://github.com/jacoco/jacoco/issues/1676 -->
+    <jacoco.append.it.file>false</jacoco.append.it.file><!-- set to true to always append for integration test coverage, overwrites default due to https://github.com/jacoco/jacoco/issues/1676 -->
 
     <project.build.outputTimestamp>2024-07-04T18:52:57Z</project.build.outputTimestamp>
 
@@ -135,6 +137,7 @@ under the License.
     <version.maven-source-plugin>3.3.1</version.maven-source-plugin>
     <version.maven-surefire>${surefire.version}</version.maven-surefire>
     <version.maven-war-plugin>3.4.0</version.maven-war-plugin>
+    <version.jacoco-maven-plugin>0.8.12</version.jacoco-maven-plugin>
   </properties>
 
   <repositories>
@@ -346,6 +349,46 @@ under the License.
           <artifactId>apache-rat-plugin</artifactId>
           <version>${version.apache-rat-plugin}</version>
         </plugin>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>${version.jacoco-maven-plugin}</version>
+          <!-- generate reports for UT and IT coverage separately -->
+          <executions>
+            <execution>
+              <id>default-prepare-agent</id>
+              <goals>
+                <goal>prepare-agent</goal>
+              </goals>
+              <configuration>
+                <!-- always create a new execution data file (https://github.com/jacoco/jacoco/issues/1676) -->
+                <append>${jacoco.append.ut.file}</append>
+              </configuration>
+            </execution>
+            <execution>
+              <id>default-prepare-agent-integration</id>
+              <goals>
+                <goal>prepare-agent-integration</goal>
+              </goals>
+              <configuration>
+                <!-- always create a new execution data file (https://github.com/jacoco/jacoco/issues/1676) -->
+                <append>${jacoco.append.it.file}</append>
+              </configuration>
+            </execution>
+            <execution>
+              <id>default-report</id>
+              <goals>
+                <goal>report</goal>
+              </goals>
+            </execution>
+            <execution>
+              <id>default-report-integration</id>
+              <goals>
+                <goal>report-integration</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>
@@ -517,14 +560,25 @@ under the License.
       </build>
     </profile>
     <!-- END SNIPPET: release-profile -->
+    <profile>
+      <id>coverage</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.jacoco</groupId>
+            <artifactId>jacoco-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
     <profile>
       <id>jdk9+</id>
       <activation>
-        <!-- this does not support toolchains, https://issues.apache.org/jira/browse/MNG-6943 -->
+                <!-- this does not support toolchains, https://issues.apache.org/jira/browse/MNG-6943 -->
         <jdk>[9,)</jdk>
       </activation>
       <properties>
-        <!-- https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html, affects m-compiler-p and m-javadoc-p -->
+                <!-- https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html, affects m-compiler-p and m-javadoc-p -->
         <maven.compiler.release>${maven.compiler.target}</maven.compiler.release>
       </properties>
     </profile>
@@ -538,7 +592,7 @@ under the License.
       <build>
         <pluginManagement>
           <plugins>
-            <!-- Disable execution of some plugins in m2e (https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html) -->
+                        <!-- Disable execution of some plugins in m2e (https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html) -->
             <plugin>
               <groupId>org.eclipse.m2e</groupId>
               <artifactId>lifecycle-mapping</artifactId>
@@ -547,7 +601,7 @@ under the License.
                 <lifecycleMappingMetadata>
                   <pluginExecutions>
                     <pluginExecution>
-                      <!-- no native m2e support yet (https://issues.apache.org/jira/browse/MRRESOURCES-85) -->
+                                            <!-- no native m2e support yet (https://issues.apache.org/jira/browse/MRRESOURCES-85) -->
                       <pluginExecutionFilter>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-remote-resources-plugin</artifactId>