<?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 
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.gatekeeperx</groupId>
    <artifactId>events-api-sdk</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>GatekeeperX Events API SDK</name>
    <description>Official Java SDK for GatekeeperX Events API</description>
    <url>https://github.com/gatekeeperx/gatekeeperx-java</url>
    <scm>
        <url>https://github.com/gatekeeperx/gatekeeperx-java</url>
        <connection>scm:git:git://github.com/gatekeeperx/gatekeeperx-java.git</connection>
        <developerConnection>scm:git:ssh://github.com/gatekeeperx/gatekeeperx-java.git</developerConnection>
    </scm>

    <licenses>
        <license>
            <name>Proprietary</name>
            <url>https://gatekeeperx.com/license</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>GatekeeperX Team</name>
            <email>support@gatekeeperx.com</email>
            <organization>GatekeeperX</organization>
            <organizationUrl>https://gatekeeperx.com</organizationUrl>
        </developer>
    </developers>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        
        <!-- Dependency Versions -->
        <okhttp.version>4.12.0</okhttp.version>
        <jackson.version>2.16.1</jackson.version>
        <slf4j.version>2.0.9</slf4j.version>
        <lombok.version>1.18.30</lombok.version>
        <jakarta.validation.version>3.0.2</jakarta.validation.version>
        
        <!-- Test Dependencies -->
        <junit.version>5.10.1</junit.version>
        <mockito.version>5.8.0</mockito.version>
        <assertj.version>3.25.1</assertj.version>
        
        <!-- Deployment control properties -->
        <deploy.nexus.skip>false</deploy.nexus.skip>
        <deploy.ossrh.skip>true</deploy.ossrh.skip>
    </properties>

    <dependencies>
        <!-- HTTP Client -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>${okhttp.version}</version>
        </dependency>

        <!-- JSON Processing -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <!-- Lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Validation -->
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <version>${jakarta.validation.version}</version>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver</artifactId>
            <version>${okhttp.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Compiler Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

            <!-- Surefire Plugin (Unit Tests) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.3</version>
            </plugin>

            <!-- Jacoco Plugin (Code Coverage) -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.11</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>INSTRUCTION</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.04</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- JavaDoc Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.6.3</version>
                <configuration>
                    <source>11</source>
                    <doclint>none</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Source Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- GPG Plugin for signing artifacts (required for Maven Central) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.2.7</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <skip>${deploy.ossrh.skip}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Deploy Plugin - Configure to deploy to internal Nexus -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <!-- Default deploy uses distributionManagement (nexus) -->
                    <repositoryId>nexus</repositoryId>
                    <skip>${deploy.nexus.skip}</skip>
                </configuration>
            </plugin>

            <!-- Central Publishing Plugin for Maven Central (OSSRH) -->
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.6.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>true</autoPublish>
                    <skip>${deploy.ossrh.skip}</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>nexus</id> <!-- debe coincidir con settings.xml -->
            <url>https://nexus.gatekeeperx.com/repository/maven-releases/</url>
        </repository>
    </repositories>

    <distributionManagement>
        <!-- Internal Gatekeeperx Nexus - used by default deploy goal -->
        <repository>
            <id>nexus</id> <!-- debe coincidir con settings.xml -->
            <url>https://nexus.gatekeeperx.com/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id> <!-- debe coincidir con settings.xml -->
            <url>https://nexus.gatekeeperx.com/repository/maven-snapshots/</url>
        </snapshotRepository>
        <!-- Maven Central (OSSRH) is deployed via deploy-file executions in maven-deploy-plugin -->
    </distributionManagement>

    <profiles>
        <!-- Profile: Deploy to internal Nexus only (default) -->
        <profile>
            <id>deploy-nexus</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <deploy.nexus.skip>false</deploy.nexus.skip>
                <deploy.ossrh.skip>true</deploy.ossrh.skip>
            </properties>
        </profile>

        <!-- Profile: Deploy to Maven Central (OSSRH) only -->
        <profile>
            <id>deploy-ossrh</id>
            <properties>
                <deploy.nexus.skip>true</deploy.nexus.skip>
                <deploy.ossrh.skip>false</deploy.ossrh.skip>
            </properties>
        </profile>

        <!-- Profile: Deploy to both repositories -->
        <profile>
            <id>deploy-both</id>
            <properties>
                <deploy.nexus.skip>false</deploy.nexus.skip>
                <deploy.ossrh.skip>false</deploy.ossrh.skip>
            </properties>
        </profile>
    </profiles>
</project>

