<?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>

    <!-- ─────────────────────────────── Coordinates ─────────────────────────────── -->
    <groupId>in.buddyai</groupId>
    <artifactId>locallm-client</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>locallm-client</name>
    <description>Java client library for LM Studio local LLM server – supports OpenAI-compatible,
        LM Studio Native, and Responses APIs with SSE streaming.</description>
    <url>https://github.com/buddyai/locallm-client</url>

    <!-- ─────────────────────────────── License ──────────────────────────────────── -->
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>

    <!-- ─────────────────────────────── Developers ───────────────────────────────── -->
    <developers>
        <developer>
            <id>buddyai</id>
            <name>BuddyAI Team</name>
            <email>info@buddyai.com</email>
        </developer>
    </developers>

    <!-- ─────────────────────────────── SCM ──────────────────────────────────────── -->
    <scm>
        <connection>scm:git:git://github.com/buddyai/locallm-client.git</connection>
        <developerConnection>scm:git:ssh://github.com/buddyai/locallm-client.git</developerConnection>
        <url>https://github.com/buddyai/locallm-client</url>
        <tag>HEAD</tag>
    </scm>

    <!-- ─────────────────────────────── Properties ───────────────────────────────── -->
    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <maven.compiler.testSource>17</maven.compiler.testSource>
        <maven.compiler.testTarget>17</maven.compiler.testTarget>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Dependency versions -->
        <okhttp.version>4.12.0</okhttp.version>
        <jackson.version>2.17.1</jackson.version>
        <slf4j.version>2.0.13</slf4j.version>
        <junit.version>5.10.3</junit.version>
        <mockwebserver.version>4.12.0</mockwebserver.version>

        <!-- Plugin versions -->
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.7.0</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
        <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
        <central-publishing-plugin.version>0.5.0</central-publishing-plugin.version>
        <maven-surefire-plugin.version>3.3.0</maven-surefire-plugin.version>
        <exec-maven-plugin.version>3.5.0</exec-maven-plugin.version>
    </properties>

    <!-- ─────────────────────────────── Dependencies ─────────────────────────────── -->
    <dependencies>

        <!-- OkHttp – HTTP client + SSE streaming -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>${okhttp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp-sse</artifactId>
            <version>${okhttp.version}</version>
        </dependency>

        <!-- Jackson – JSON serialization / deserialization -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <!-- SLF4J API – logging facade (consumers wire in their own impl) -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.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>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver</artifactId>
            <version>${mockwebserver.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 ────────────────────────────────────── -->
    <build>
        <plugins>

            <!-- Compiler -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <!-- Surefire – JUnit 5 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>

            <!-- CLI runner -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <configuration>
                    <mainClass>in.buddyai.locallm.cli.LocalLmCli</mainClass>
                </configuration>
            </plugin>

            <!-- Sources JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals><goal>jar-no-fork</goal></goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Javadoc JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals><goal>jar</goal></goals>
                    </execution>
                </executions>
                <configuration>
                    <doclint>none</doclint>
                </configuration>
            </plugin>

            <!-- Release plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <!-- ─────────────────────────────── Profiles ─────────────────────────────────── -->
    <profiles>

        <!-- Release profile: GPG sign + publish to Maven Central -->
        <profile>
            <id>release</id>
            <build>
                <plugins>

                    <!-- GPG Signing (required by Central) -->
                    <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>
                                    <!-- Set gpg.keyname in ~/.m2/settings.xml or -Dgpg.keyname -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Central Publishing Plugin (new Sonatype portal) -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.9.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                            <waitUntil>published</waitUntil>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>

    </profiles>

</project>
