Skip to content

Conversation

@kameshsr
Copy link
Contributor

@kameshsr kameshsr commented Dec 22, 2025

Summary by CodeRabbit

  • Chores
    • Attach code-coverage agent to test runs and generate reports after tests.
    • Ensure build artifacts include implementation/project info in manifests; standardize compiler targets.
  • New Features
    • Reintroduce publishing pipeline: deploy, source/javadoc jars, signing, and publishing metadata.
  • Tests
    • Enable Java preview and necessary module openings during test execution.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: kameshsr <kameshsr1338@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Walkthrough

Adds JaCoCo agent wiring and adjusts plugin lifecycles across three POMs: sets a jacocoArgLine property via a prepare-agent execution, updates Surefire argLine to include ${jacocoArgLine} plus multiple --add-opens and --enable-preview, and moves Jacoco report generation to the verify phase.

Changes

Cohort / File(s) Change Summary
Jacoco agent & report executions
commons-packet/commons-packet-manager/pom.xml, commons-packet/commons-packet-service/pom.xml, commons-packet/pom.xml
Added jacoco-maven-plugin execution prepare-agent that sets <propertyName>jacocoArgLine</propertyName>; added/adjusted report execution and moved report phase to verify (from prepare-package in some POMs).
Surefire argLine and JVM flags
commons-packet/commons-packet-manager/pom.xml, commons-packet/commons-packet-service/pom.xml, commons-packet/pom.xml
Updated maven-surefire-plugin configuration argLine to include ${jacocoArgLine} and explicit --add-opens flags plus --enable-preview (restructured from previous single-line arg).
Build/deploy/plugin additions (service & root POMs)
commons-packet/commons-packet-service/pom.xml, commons-packet/pom.xml
Reintroduced/added multiple build plugins: maven-deploy-plugin, central-publishing-maven-plugin, maven-source-plugin, maven-javadoc-plugin, maven-gpg-plugin, git-commit-id-plugin; adjusted compiler configuration and relocated plugin blocks.
Manifest / jar/war metadata
commons-packet/pom.xml
Added/adjusted maven-jar-plugin / maven-war-plugin manifest entries to include implementation metadata (project name/version).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CI as Developer/CI
  participant Maven as Maven Build
  participant Jacoco as JaCoCo Plugin
  participant Surefire as Surefire Plugin
  participant Report as JaCoCo Report

  CI->>Maven: run lifecycle (test → verify)
  Maven->>Jacoco: execute prepare-agent (set `jacocoArgLine`)
  Jacoco-->>Maven: expose `${jacocoArgLine}`
  Maven->>Surefire: run tests with `${jacocoArgLine}`\n(includes --add-opens, --enable-preview, agent attached)
  Surefire-->>Maven: tests complete
  Maven->>Report: run jacoco:report (phase: verify)
  Report-->>Maven: generate coverage report
  Maven-->>CI: build finished
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nudged the POMs with a twitch and a hop,
I tucked jacoco in pockets until the tests stop,
Surefire's doors ajar, previews shining bright,
Verify sang the tally and printed the light,
Hop — coverage blooms under moonlit byte.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'MOSIP-44120 Corrected surefire and jacoco plugin' accurately describes the main changes: corrections to Maven surefire and jacoco plugin configurations across multiple pom.xml files, including argLine composition updates and lifecycle phase adjustments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
commons-packet/pom.xml (2)

26-26: Duplicate property for Jacoco version.

maven.jacoco.version (line 26) and jacoco.maven.plugin.version (line 37) both define the same value 0.8.11. Consider consolidating to a single property name for clarity and maintainability. Additionally, child modules (commons-packet-manager and commons-packet-service) also define their own jacoco.maven.plugin.version, which is redundant since they inherit from this parent.

Suggested consolidation

Remove the duplicate property and use a single consistent name:

-         <maven.jacoco.version>0.8.11</maven.jacoco.version>
          <maven.sonar.plugin.version>3.7.0.1746</maven.sonar.plugin.version>
         <maven.javadoc.version>3.2.0</maven.javadoc.version>
         <maven-shade-plugin.version>2.3</maven-shade-plugin.version>
         <maven.deploy.plugin.version>2.8.1</maven.deploy.plugin.version>
 		<maven.source.plugin.version>2.2.1</maven.source.plugin.version>
 		<maven.gpg.plugin.version>1.5</maven.gpg.plugin.version>
         <central.publishing.maven.plugin.version>0.7.0</central.publishing.maven.plugin.version>
 		<git.commit.plugin.version>3.0.1</git.commit.plugin.version>
         <sonar.coverage.exclusions>...</sonar.coverage.exclusions>
         <sonar.cpd.exclusions>**/dto/**,**/entity/**,**/config/**</sonar.cpd.exclusions>
         <jacoco.maven.plugin.version>0.8.11</jacoco.maven.plugin.version>

Child modules can then remove their local jacoco.maven.plugin.version definitions since they inherit from this parent.

Also applies to: 37-37


63-79: Parent surefire configuration will be overridden by child modules.

The child modules (commons-packet-manager and commons-packet-service) each define their own complete maven-surefire-plugin configuration. Since they fully re-declare the plugin, this parent configuration is effectively unused for those modules. This is not a bug but creates maintenance overhead—changes need to be made in three places.

Consider either:

  1. Remove surefire config from child poms and rely on parent inheritance, or
  2. Keep only in child poms and remove from parent (if modules truly need different configs)
commons-packet/commons-packet-service/pom.xml (1)

28-29: Upgrade maven-surefire-plugin to a 3.x version for improved Java 21 support.

Version 2.22.0 from 2018 lacks modern Java version support improvements. Version 3.2.5 is recommended as a stable upgrade target, with 3.5.4 available as the current version.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de4ffed and c4bc074.

📒 Files selected for processing (3)
  • commons-packet/commons-packet-manager/pom.xml
  • commons-packet/commons-packet-service/pom.xml
  • commons-packet/pom.xml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-maven-packet-manager / maven-build
🔇 Additional comments (5)
commons-packet/commons-packet-service/pom.xml (2)

261-277: Surefire configuration looks correct for Jacoco integration.

The ${jacocoArgLine} placeholder is properly included before the JVM arguments, which will be populated by Jacoco's prepare-agent goal. The --add-opens flags address Java module encapsulation for testing.

Note: <skipTests>false</skipTests> and <skip>false</skip> are redundant (both default to false), but harmless.


283-303: Jacoco plugin configuration is correct.

The prepare-agent execution properly populates jacocoArgLine which is referenced in surefire's argLine. Moving the report phase to verify ensures coverage data is collected after tests complete.

commons-packet/commons-packet-manager/pom.xml (2)

166-182: Surefire and Jacoco integration is correctly configured.

The configuration mirrors the service module with proper ${jacocoArgLine} placeholder and JVM arguments for Java 21 module access. Same note about surefire version 2.22.0 potentially being outdated for Java 21.


272-292: Jacoco configuration is consistent with the service module.

The prepare-agent and report executions follow the same correct pattern.

commons-packet/pom.xml (1)

80-107: Jacoco configuration is correct.

The prepare-agent execution properly maps to jacocoArgLine, and moving report to the verify phase ensures tests complete before report generation.

Signed-off-by: kameshsr <kameshsr1338@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Fix all issues with AI Agents 🤖
In @commons-packet/pom.xml:
- Around line 69-76: Add a default empty property for jacocoArgLine in the POM
properties (define <jacocoArgLine></jacocoArgLine>) so ${jacocoArgLine} is never
undefined, and update the maven-compiler-plugin configuration (the plugin block
that defines compilerArgs / forked JVM args) to include --enable-preview
alongside test argLine so compilation uses the same preview flag as the
surefire/failsafe test execution.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4bc074 and 26e975f.

📒 Files selected for processing (1)
  • commons-packet/pom.xml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-maven-packet-manager / maven-build
🔇 Additional comments (2)
commons-packet/pom.xml (2)

84-104: JaCoCo configuration is correctly integrated.

The prepare-agent execution with propertyName properly exposes the agent arguments to Surefire, and moving the report generation to the verify phase ensures coverage data is collected after tests complete. This is the recommended approach for JaCoCo + Surefire integration.


108-124: LGTM!

The maven-jar-plugin configuration correctly adds manifest metadata including classpath, default implementation entries, and project-specific attributes.

Signed-off-by: kameshsr <kameshsr1338@gmail.com>
Signed-off-by: kameshsr <kameshsr1338@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Fix all issues with AI Agents 🤖
In @commons-packet/pom.xml:
- Line 68: Remove the hardcoded <skipTests>false</skipTests> element so Maven
respects the -DskipTests CLI property; alternatively replace it with a property
reference (e.g., use the skipTests Maven property like ${skipTests}) or remove
the element entirely to rely on Maven defaults, ensuring the <skipTests> element
is not hardcoded to "false".
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9401030 and bc2673c.

📒 Files selected for processing (1)
  • commons-packet/pom.xml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-maven-packet-manager / maven-build
🔇 Additional comments (3)
commons-packet/pom.xml (3)

37-37: LGTM!

The empty default for jacocoArgLine prevents build failures when JaCoCo is skipped or disabled.


150-152: LGTM!

The --enable-preview flag correctly enables Java preview features for compilation, ensuring consistency with the Surefire test configuration.


98-104: This review comment is incorrect. The report goal is the appropriate choice for this multi-module structure. Both child modules (commons-packet-manager and commons-packet-service) have identical JaCoCo configurations using the report goal, confirming this is the intended design pattern. Each module generates independent coverage reports during the verify phase; no aggregation across modules is configured or needed in this codebase.

Likely an incorrect or invalid review comment.

Signed-off-by: kameshsr <kameshsr1338@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Fix all issues with AI Agents 🤖
In @commons-packet/pom.xml:
- Line 69: Remove the hardcoded <skip>false</skip> element so command-line
test-skipping works; either delete the <skip> element entirely or replace its
value with a Maven property (e.g. <skip>${maven.test.skip}</skip> or
<skip>${skipTests}</skip>) so users can control test execution with
-Dmaven.test.skip=true or -DskipTests=true; update the plugin configuration that
contains the <skip> element accordingly (look for the <skip> tag in the plugin
configuration).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc2673c and d7c7d99.

📒 Files selected for processing (1)
  • commons-packet/pom.xml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-maven-packet-manager / maven-build
🔇 Additional comments (4)
commons-packet/pom.xml (4)

37-37: LGTM!

The empty default for jacocoArgLine ensures the build won't break if JaCoCo's prepare-agent goal is skipped.


70-77: LGTM!

The argLine correctly integrates ${jacocoArgLine} with the necessary --add-opens flags for Java 21 module access and maintains consistency with the compiler's --enable-preview flag.


85-105: LGTM!

The JaCoCo configuration is correct:

  • prepare-agent properly binds the agent to jacocoArgLine for Surefire integration
  • report phase moved to verify ensures coverage data is collected after tests complete

150-152: LGTM!

Adding --enable-preview to the compiler ensures consistency between compilation and test execution, as addressed from the previous review.

Signed-off-by: kameshsr <kameshsr1338@gmail.com>
Signed-off-by: kameshsr <kameshsr1338@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @commons-packet/commons-packet-service/pom.xml:
- Around line 258-276: The jacoco-maven-plugin is configured with the
prepare-agent goal but the Surefire test runner is not configured to use the
generated agent args, so tests won't be instrumented; update the
jacoco-maven-plugin prepare-agent execution to set a property name (e.g.,
jacocoArgLine) and then add a maven-surefire-plugin entry that sets its
<argLine> to reference ${jacocoArgLine} (and include any required JVM flags like
--add-opens/--enable-preview if needed), ensuring the prepare-agent populates
the property and Surefire uses it during test execution.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7c7d99 and 9a24b92.

📒 Files selected for processing (2)
  • commons-packet/commons-packet-service/pom.xml
  • commons-packet/pom.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • commons-packet/pom.xml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-maven-packet-manager / maven-build
🔇 Additional comments (4)
commons-packet/commons-packet-service/pom.xml (4)

160-232: LGTM! Standard Maven Central publishing configuration.

The maven-deploy-plugin, central-publishing-maven-plugin, maven-source-plugin, maven-javadoc-plugin, and maven-gpg-plugin are configured correctly for publishing to Maven Central/OSSRH. The autoPublish=false setting provides a safety check by requiring manual promotion.


233-257: LGTM! Git metadata plugin configured appropriately.

The git-commit-id-plugin will generate build metadata in the validate phase with sensible property filtering.


279-298: LGTM! Project metadata sections added.

The SCM, license, and developer information sections are correctly configured for Maven Central publishing requirements.


270-270: The technical reasoning in this review is incorrect. According to the Maven lifecycle, the test phase completes before the prepare-package phase begins. Coverage data from tests is available during prepare-package, so the claim that this phase may generate reports "before all tests have run" is unfounded.

That said, there is inconsistency in this repository: commons-packet/commons-packet-manager/pom.xml uses the verify phase with a comment indicating this was "fixed," while other modules use prepare-package. While jacoco:report (report generation) is valid in either phase per JaCoCo documentation, aligning all modules to the same phase would improve consistency.

Consider either: (1) keeping prepare-package and removing the inconsistent verify usage in commons-packet-manager, or (2) standardizing all modules to verify phase for consistency with commons-packet-manager.

Likely an incorrect or invalid review comment.

Comment on lines +258 to +276
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: JaCoCo agent won't be attached without Surefire plugin configuration.

The jacoco-maven-plugin's prepare-agent goal is configured, but there's no maven-surefire-plugin configuration to reference the JaCoCo agent property in its argLine. Without this, the JaCoCo agent won't instrument test execution, and no coverage data will be collected.

🔎 Required Surefire plugin configuration

Add the maven-surefire-plugin after the jacoco-maven-plugin (around line 277):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>${jacocoArgLine} --add-opens java.base/java.lang=ALL-UNNAMED --enable-preview</argLine>
    </configuration>
</plugin>

Additionally, update the jacoco-maven-plugin's prepare-agent execution to explicitly set the property name:

 <execution>
+    <configuration>
+        <propertyName>jacocoArgLine</propertyName>
+    </configuration>
     <goals>
         <goal>prepare-agent</goal>
     </goals>
 </execution>

This ensures the JaCoCo agent arguments are stored in ${jacocoArgLine} and then referenced by Surefire.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>
<execution>
<configuration>
<propertyName>jacocoArgLine</propertyName>
</configuration>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
🤖 Prompt for AI Agents
In @commons-packet/commons-packet-service/pom.xml around lines 258-276, The
jacoco-maven-plugin is configured with the prepare-agent goal but the Surefire
test runner is not configured to use the generated agent args, so tests won't be
instrumented; update the jacoco-maven-plugin prepare-agent execution to set a
property name (e.g., jacocoArgLine) and then add a maven-surefire-plugin entry
that sets its <argLine> to reference ${jacocoArgLine} (and include any required
JVM flags like --add-opens/--enable-preview if needed), ensuring the
prepare-agent populates the property and Surefire uses it during test execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants