Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions commons-packet/commons-packet-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,23 @@
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<skip>false</skip>
<argLine>
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --enable-preview
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<skip>false</skip>
<argLine>
${jacocoArgLine}
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--enable-preview
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -264,21 +269,30 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.maven.plugin.version}</version>
<executions>

<!-- FIXED: attach jacoco to surefire -->
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacocoArgLine</propertyName>
</configuration>
</execution>

<!-- FIXED: generate report AFTER test phase -->
<execution>
<id>report</id>
<phase>prepare-package</phase>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>

</executions>
</plugin>
<plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>${git.commit.plugin.version}</version>
Expand Down
283 changes: 140 additions & 143 deletions commons-packet/commons-packet-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
<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>

<git.commit.plugin.version>3.0.1</git.commit.plugin.version>
<!-- spring -->
<kernel.keygenerator.bouncycastle.version>1.2.1-SNAPSHOT</kernel.keygenerator.bouncycastle.version>
<swagger.version>2.10.0</swagger.version>

<kernel.core.version>1.2.1-SNAPSHOT</kernel.core.version>
<kernel.biometrics.api.version>1.2.1-SNAPSHOT</kernel.biometrics.api.version>
<kernel.crypto-jce.version>1.2.1-SNAPSHOT</kernel.crypto-jce.version>
Expand Down Expand Up @@ -159,146 +157,145 @@
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven.deploy.plugin.version}</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central.publishing.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>ossrh</publishingServerId>
<autoPublish>false</autoPublish>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<version>${maven.source.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<doclint>none</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven.gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>${git.commit.plugin.version}</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/service-git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<!-- <format>json</format> -->
</configuration>
</plugin>

<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>
</plugins>
</build>
<scm>
<connection>scm:git:git://github.com/mosip/packet-manager.git</connection>
<developerConnection>scm:git:ssh://github.com:mosip/packet-manager.git</developerConnection>
<url>https://github.com/mosip/commons</url>
<tag>HEAD</tag>
</scm>
<licenses>
<license>
<name>MPL 2.0</name>
<url>https://www.mozilla.org/en-US/MPL/2.0/</url>
</license>
</licenses>
<developers>
<developer>
<name>Mosip</name>
<email>[email protected]</email>
<organization>io.mosip</organization>
<organizationUrl>https://github.com/mosip/commons</organizationUrl>
</developer>
</developers>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven.deploy.plugin.version}</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>${central.publishing.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>ossrh</publishingServerId>
<autoPublish>false</autoPublish>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<version>${maven.source.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<doclint>none</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven.gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>${git.commit.plugin.version}</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/service-git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<!-- <format>json</format> -->
</configuration>
</plugin>
<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>
Comment on lines +258 to +276
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.

</plugins>
</build>
<scm>
<connection>scm:git:git://github.com/mosip/packet-manager.git</connection>
<developerConnection>scm:git:ssh://github.com:mosip/packet-manager.git</developerConnection>
<url>https://github.com/mosip/commons</url>
<tag>HEAD</tag>
</scm>
<licenses>
<license>
<name>MPL 2.0</name>
<url>https://www.mozilla.org/en-US/MPL/2.0/</url>
</license>
</licenses>
<developers>
<developer>
<name>Mosip</name>
<email>[email protected]</email>
<organization>io.mosip</organization>
<organizationUrl>https://github.com/mosip/commons</organizationUrl>
</developer>
</developers>
<profiles>
<profile>
<id>openapi-doc-generate-profile</id>
Expand Down
Loading
Loading