<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>xyz.tcheeric</groupId>
    <artifactId>nostr-java</artifactId>
    <version>2.0.1</version>
    <packaging>pom</packaging>

    <name>nostr-java</name>
    <description>Java SDK for Nostr, for generating, signing and publishing events to relays</description>
    <url>https://github.com/tcheeric/nostr-java</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>@tcheeric</name>
        </developer>
        <developer>
            <name>@avlo</name>
        </developer>
        <developer>
            <name>@guilhermegps</name>
        </developer>
        <developer>
            <name>@devinbileck</name>
        </developer>
        <developer>
            <name>@Memory-of-Snow</name>
        </developer>
        <developer>
            <name>@austenjt</name>
        </developer>
        <developer>
            <name>@maxbrito500</name>
        </developer>
        <developer>
            <name>@KoalaSat</name>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/tcheeric/nostr-java.git</connection>
        <developerConnection>scm:git:ssh://github.com:tcheeric/nostr-java.git</developerConnection>
        <url>https://github.com/tcheeric/nostr-java/tree/main</url>
    </scm>

    <distributionManagement>
        <repository>
            <id>reposilite-releases</id>
            <url>https://maven.398ja.xyz/releases</url>
        </repository>
        <snapshotRepository>
            <id>reposilite-snapshots</id>
            <url>https://maven.398ja.xyz/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <modules>
        <!-- Build order adjusted to satisfy inter-module dependencies -->
        <module>nostr-java-core</module>
        <module>nostr-java-event</module>
        <module>nostr-java-identity</module>
        <module>nostr-java-client</module>
    </modules>

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

        <!-- All versions now managed by nostr-java-bom -->
        <nostr-java-bom.version>1.1.8</nostr-java-bom.version>

        <!-- Plugin versions -->
        <central.publishing.plugin.version>0.10.0</central.publishing.plugin.version>
        <maven.source.plugin.version>3.3.1</maven.source.plugin.version>
        <maven.javadoc.plugin.version>3.11.3</maven.javadoc.plugin.version>
        <maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
        <flatten.plugin.version>1.7.2</flatten.plugin.version>
        <maven.compiler.plugin.version>3.14.0</maven.compiler.plugin.version>
        <maven.surefire.plugin.version>3.5.3</maven.surefire.plugin.version>
        <jacoco.plugin.version>0.8.14</jacoco.plugin.version>
        <maven.failsafe.plugin.version>3.5.3</maven.failsafe.plugin.version>
    </properties>

    <!-- parent pom is used only for aggregation so it should not declare
         any direct dependencies. Module specific dependencies are
         defined in each sub module pom -->

    <dependencyManagement>
        <dependencies>
            <!-- Import Nostr Java BOM - manages all dependency versions -->
            <dependency>
                <groupId>xyz.tcheeric</groupId>
                <artifactId>nostr-java-bom</artifactId>
                <version>${nostr-java-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- JUnit alignment now provided by nostr-java-bom -->
            <!-- Temporary overrides: ensure reactor uses current module versions until BOM is updated -->
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>nostr-java-core</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>nostr-java-event</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>nostr-java-identity</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>nostr-java-client</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <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>
                        <autoPublish>true</autoPublish>
                        <waitUntil>published</waitUntil>
                    </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>
                        <doclint>none</doclint>
                        <quiet>true</quiet>
                        <source>21</source>
                        <detectJavaApiLink>false</detectJavaApiLink>
                        <additionalOptions>
                            <additionalOption>-Xdoclint:none</additionalOption>
                        </additionalOptions>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <sourcepath>${project.build.sourceDirectory};${project.build.directory}/generated-sources/annotations</sourcepath>
                            </configuration>
                        </execution>
                    </executions>
                </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>
                                <!--suppress UnresolvedMavenProperty -->
                                <keyname>${gpg.keyname}</keyname>
                                <!--suppress UnresolvedMavenProperty -->
                                <passphraseServerId>${gpg.keyname}</passphraseServerId>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>flatten-maven-plugin</artifactId>
                    <version>${flatten.plugin.version}</version>
                    <configuration>
                        <updatePomFile>true</updatePomFile>
                        <flattenMode>resolveCiFriendliesOnly</flattenMode>
                    </configuration>
                    <executions>
                        <execution>
                            <id>flatten</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>flatten</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>flatten.clean</id>
                            <phase>clean</phase>
                            <goals>
                                <goal>clean</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>1.18.36</version>
                            </path>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <rerunFailingTestsCount>1</rerunFailingTestsCount>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <mockito.mock-maker>subclass</mockito.mock-maker>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven.failsafe.plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <mockito.mock-maker>subclass</mockito.mock-maker>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
        </plugins>

    </build>

    <profiles>
        <!-- Use when running in environments without Docker to skip Testcontainers-based ITs -->
        <profile>
            <id>no-docker</id>
            <properties>
                <noDocker>true</noDocker>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <excludes>
                                <!-- Skip Docker/Testcontainers-backed tests in API module -->
                                <exclude>**/nostr/api/integration/**</exclude>
                            </excludes>
                            <systemPropertyVariables>
                                <noDocker>true</noDocker>
                                <mockito.mock-maker>subclass</mockito.mock-maker>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${maven.failsafe.plugin.version}</version>
                        <configuration>
                            <excludes>
                                <!-- Skip Docker/Testcontainers-backed ITs in API module -->
                                <exclude>**/nostr/api/integration/**</exclude>
                            </excludes>
                            <systemPropertyVariables>
                                <noDocker>true</noDocker>
                                <mockito.mock-maker>subclass</mockito.mock-maker>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Publish to 398ja Reposilite repository -->
        <profile>
            <id>release-398ja</id>
            <distributionManagement>
                <repository>
                    <id>reposilite-releases</id>
                    <url>https://maven.398ja.xyz/releases</url>
                </repository>
                <snapshotRepository>
                    <id>reposilite-snapshots</id>
                    <url>https://maven.398ja.xyz/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
            <repositories>
                <repository>
                    <id>reposilite-releases</id>
                    <url>https://maven.398ja.xyz/releases</url>
                </repository>
                <repository>
                    <id>reposilite-snapshots</id>
                    <url>https://maven.398ja.xyz/snapshots</url>
                </repository>
            </repositories>
        </profile>

        <!-- Publish to Maven Central using Central Publishing plugin -->
        <profile>
            <id>release-central</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-maven-plugin</artifactId>
                        <version>1.18.20.0</version>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>delombok</goal>
                                </goals>
                                <configuration>
                                    <addOutputDirectory>false</addOutputDirectory>
                                    <sourceDirectory>src/main/java</sourceDirectory>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>1.18.36</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <doclint>none</doclint>
                            <quiet>true</quiet>
                            <source>21</source>
                            <detectJavaApiLink>false</detectJavaApiLink>
                            <additionalOptions>
                                <additionalOption>-Xdoclint:none</additionalOption>
                            </additionalOptions>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <sourcepath>${project.build.directory}/generated-sources/delombok</sourcepath>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven.gpg.plugin.version}</version>
                        <configuration>
                            <passphrase>${env.GPG_PASSPHRASE}</passphrase>
                            <gpgArguments>
                                <arg>--batch</arg>
                                <arg>--yes</arg>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central.publishing.plugin.version}</version>
                        <extensions>true</extensions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
