<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>4.0.7</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <!-- Quankee Common Framework -->
    <groupId>mz.co.quankee.framework</groupId>
    <artifactId>quankee-framework-common</artifactId> 
    <version>2.2.7</version>
    <packaging>pom</packaging>
    <name>Quankee Framework Common</name>
    <description>Quankee Framework Common</description>

    <!-- properties -->
    <properties>
        <java.version>17</java.version>
        <spring-cloud.version>2025.1.1</spring-cloud.version>

        <!-- Logback Appender For Loki -->
        <loki4j.version>2.0.3</loki4j.version>

        <!-- Test -->
        <jacoco.maven.plugin.version>0.8.13</jacoco.maven.plugin.version>
    </properties>

    <!-- Modules -->
    <modules>
        <module>quankee-framework-common-base</module>
        <module>quankee-framework-common-domain</module>
        <module>quankee-framework-common-kafka</module>
        <module>quankee-framework-common-aspect</module>
        <module>quankee-framework-common-repository</module>
        <module>quankee-framework-common-openfeign</module>
        <module>quankee-framework-common-service</module>
        <module>quankee-framework-common-controller</module>
        <module>quankee-framework-common-manager</module>
        <module>quankee-framework-common-main</module>
    </modules>

    <dependencies>

        <!--Springboot Dependencies -->
        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-kafka</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <dependencyManagement>

        <dependencies>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-base</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-domain</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-kafka</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-aspect</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-repository</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-openfeign</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>mz.co.quankee.framework</groupId>
                <artifactId>quankee-framework-common-service</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- Spring Cloud -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>

    </dependencyManagement>

    <!-- Release Management -->
    <scm>
        <connection>scm:git:https://gitlab.com/quankee-framework/quankee-framework-common.git</connection>
        <developerConnection>scm:git:https://gitlab.com/quankee-framework/quankee-framework-common.git</developerConnection>
        <tag>quankee-framework-common-2.2.7</tag>
    </scm>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>guambino</id>
            <name>Ivan Guambe</name>
            <email>ivan.guambe@quankee.co.mz</email>
        </developer>
    </developers>

    <build>
        <!-- Plugin Management -->
        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                            </exclude>
                        </excludes>
                    </configuration>
                </plugin>

                <!-- Sources -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                </plugin>

                <!-- Javadocs -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <configuration>
                        <source>17</source>
                        <failOnError>false</failOnError>
                        <doclint>none</doclint>
                    </configuration>
                </plugin>

                <!-- GPG -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                </plugin>

            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Deployment -->
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.10.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>quankee-repo</publishingServerId>
                </configuration>
            </plugin>

            <!-- Attach sources -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Attach javadocs -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Sign everything -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <gpgArguments>
                                <arg>--batch</arg>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <useReleaseProfile>true</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles> <!-- activate our release profile -->
                </configuration>
            </plugin>

            <!-- Coverage -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <configuration>
                    <haltOnFailure>true</haltOnFailure>
                    <rules>
                        <rule>
                            <element>CLASS</element>
                            <excludes>
                                <exclude>mz.co.quankee.framework.common.base.exception.UnableToFormatDateException</exclude>
                                <exclude>mz.co.quankee.framework.common.base.exception.ValidationException</exclude>
                                <exclude>mz.co.quankee.framework.common.base.exception.ItemLinkedException</exclude>
                                <exclude>mz.co.quankee.framework.common.base.exception.DataConversionException</exclude>
                                <exclude>mz.co.quankee.framework.common.base.util.StringIdentifierGenerator</exclude>
                                <exclude>mz.co.quankee.framework.common.base.exception.ItemNotFoundException</exclude>
                                <exclude>mz.co.quankee.framework.common.kafka.config.FrameworkKafKaConfig</exclude>
                                <exclude>mz.co.quankee.framework.common.kafka.impl.AuditTrailProducerImpl</exclude>
                                <exclude>mz.co.quankee.framework.common.base.crude.CommonErrorMessages</exclude>
                                <exclude>mz.co.quankee.framework.common.service.config.SpringContext</exclude>
                                <exclude>mz.co.quankee.framework.common.service.config.FrameworkServiceConfig</exclude>
                                <exclude>mz.co.quankee.framework.common.service.info.impl.ApplicationInfoServiceImpl</exclude>
                                <exclude>mz.co.quankee.framework.common.service.AbstractCommonService</exclude>
                                <exclude>mz.co.quankee.framework.common.service.base.impl.ContactServiceImpl</exclude>
                                <exclude>mz.co.quankee.framework.common.service.repository.impl.ItemRepositoryCustomImpl</exclude>
                                <exclude>mz.co.quankee.framework.common.QuankeeFrameworkCommonApplication</exclude>
                            </excludes>
                            <limits>
                                <limit>
                                    <counter>INSTRUCTION</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>0.8</minimum>
                                </limit>
                                <limit>
                                    <counter>LINE</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>0.8</minimum>
                                </limit>
                                <limit>
                                    <counter>BRANCH</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>0.8</minimum>
                                </limit>
                            </limits>
                        </rule>
                    </rules>
                </configuration>
                <executions>
                    <execution>
                        <id>jacoco-check</id>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>


    </build>

    <profiles>
        <!-- Release profile: only active when explicitly enabled -->
        <profile>
            <id>release</id>
            <build>
                <plugins>

                    <!-- Attach sources -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>

                    </plugin>

                    <!-- Attach javadocs -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- Avoid empty javadoc JARs -->
                            <failOnError>false</failOnError>
                            <source>17</source>
                            <encoding>UTF-8</encoding>
                            <doclint>none</doclint>
                        </configuration>
                    </plugin>

                    <!-- GPG signing -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <gpgArguments>
                                <arg>--batch</arg>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>
</project>