<?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>

    <groupId>io.github.cyfko</groupId>
    <artifactId>projection-spec</artifactId>
    <version>2.0.0</version>
    <packaging>jar</packaging>

    <name>Projection Specification</name>
    <description>Annotation specification for DTO projections, computed fields, and provider configuration in Java.</description>
    <url>https://github.com/cyfko/projection-spec</url>
    <inceptionYear>2025</inceptionYear>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Frank KOSSI</name>
            <email>frank.kossi@kunrin.com</email>
            <organization>Kunrin SA</organization>
            <organizationUrl>https://www.kunrin.com</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/cyfko/projection-spec.git</connection>
        <!-- CORRECTION: Utilisation de la syntaxe standard git@ pour l'accès SSH (écriture) -->
        <developerConnection>scm:git:git@github.com:cyfko/projection-spec.git</developerConnection>
        <url>https://github.com/cyfko/projection-spec/tree/main</url>
        <tag>v2.0.0</tag>
    </scm>

    <properties>
        <java.version>21</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.10.1</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
        <!-- AJOUT: Version explicite du release plugin -->
        <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
        <central-publishing-plugin.version>0.7.0</central-publishing-plugin.version>
    </properties>

    <dependencies>
        <!-- No dependencies for pure annotation spec -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <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>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <doclint>none</doclint>
                    <quiet>true</quiet>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- AJOUT CRITIQUE : Configuration du Maven Release Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <!-- Créer des tags du style v1.0.0 au lieu de projection-spec-1.0.0 -->
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <!-- Important: Activer le profil 'release' lors de l'exécution (perform) -->
                    <!-- Cela garantit que GPG et le Central Publishing plugin s'exécutent -->
                    <releaseProfiles>release</releaseProfiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <!-- AJOUT: Publier automatiquement si la validation passe -->
<!--                            <autoPublish>true</autoPublish>-->
<!--                            <waitUntil>published</waitUntil>-->
                        </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>-->
<!--                                    &lt;!&ndash; Évite le prompt de passphrase si gpg-agent est configuré &ndash;&gt;-->
<!--                                    <gpgArguments>-->
<!--                                        <arg>&#45;&#45;pinentry-mode</arg>-->
<!--                                        <arg>loopback</arg>-->
<!--                                    </gpgArguments>-->
<!--                                </configuration>-->
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <!-- Note: Avec central-publishing-maven-plugin, le repository 'releases' ci-dessous
             n'est techniquement pas utilisé pour l'upload final vers le nouveau portail,
             mais il est bon de le laisser pour la compatibilité Maven standard. -->
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
</project>