<?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>io.axoniq.license</groupId>
    <artifactId>entitlement-manager</artifactId>
    <version>1.3.2</version>

    <name>Entitlement Manager</name>
    <description>Axoniq Entitlement Manager for license validation and entitlement management</description>
    <url>https://github.com/AxonIQ/entitlement-manager</url>

    <licenses>
        <license>
            <name>Axoniq Terms of Service</name>
            <url>https://www.axoniq.io/legal/terms-of-service</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>AxonIQ B.V</name>
            <organization>AxonIQ</organization>
            <organizationUrl>https://www.axoniq.io</organizationUrl>
        </developer>
    </developers>

    <scm>
        <url>https://github.com/AxonIQ/entitlement-manager</url>
        <connection>scm:git:git://github.com/AxonIQ/entitlement-manager.git</connection>
        <developerConnection>scm:git:ssh://github.com:AxonIQ/entitlement-manager.git</developerConnection>
    </scm>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.jspecify</groupId>
            <artifactId>jspecify</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>1.14.2</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.axoniq.framework</groupId>
            <artifactId>axon-server-connector</artifactId>
            <version>5.1.1</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.axoniq.platform</groupId>
            <artifactId>axoniq-platform-framework-client</artifactId>
            <version>5.2.1</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-inprocess</artifactId>
            <version>1.76.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.14.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.21.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-messaging</artifactId>
            <version>5.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.5.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>4.2.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Copy dependencies for Allatori classpath -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Copy and filter allatori.xml (resolves Maven properties) -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>copy-and-filter-allatori-config</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/allatori</directory>
                                    <includes>
                                        <include>allatori.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>obfuscate</id>
            <activation>
                <file>
                    <exists>${basedir}/allatori/allatori.jar</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <!-- Running Allatori obfuscator -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>run-allatori</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-Xms128m</argument>
                                <argument>-Xmx512m</argument>
                                <argument>-jar</argument>
                                <argument>${basedir}/allatori/allatori.jar</argument>
                                <argument>${basedir}/target/allatori.xml</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                        </configuration>
                    </plugin>
                    <!-- Empty sources JAR to satisfy Maven Central requirements -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.4.2</version>
                        <executions>
                            <execution>
                                <id>empty-sources-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>sources</classifier>
                                    <classesDirectory>${project.basedir}/src/main/resources</classesDirectory>
                                    <includes>
                                        <include>META-INF/MANIFEST.MF</include>
                                    </includes>
                                </configuration>
                            </execution>
                            <execution>
                                <id>empty-javadoc-jar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>javadoc</classifier>
                                    <classesDirectory>${project.basedir}/src/main/resources</classesDirectory>
                                    <includes>
                                        <include>META-INF/MANIFEST.MF</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>sign</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.4</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

    <repositories>
        <repository>
            <id>axoniq-nexus</id>
            <url>https://nexus.dev.axoniq.net/repository/products/</url>
        </repository>
        <repository>
            <name>Central Portal Snapshots</name>
            <id>central-portal-snapshots</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>
