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

    <parent>
        <groupId>xyz.tcheeric</groupId>
        <artifactId>gateway-plugin</artifactId>
        <version>1.2.7</version>
    </parent>

    <artifactId>gateway-app</artifactId>
    <name>Gateway Application</name>
    <description>Spring Boot application for the Cashu Gateway</description>

    <dependencies>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>gateway-rest</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>gateway-security</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>identity-infrastructure</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>identity-application</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>gateway-api</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Wallet Plugin Integration (Phase 5.7) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-app</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Force cashu-lib to override transitive deps -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>cashu-lib-common</artifactId>
            <version>${cashu-lib.version}</version>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>cashu-lib-entities</artifactId>
            <version>${cashu-lib.version}</version>
        </dependency>
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>cashu-lib-crypto</artifactId>
            <version>${cashu-lib.version}</version>
        </dependency>

        <!-- Nostr integration for voucher backup (Phase 5.8) -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-core-nostr</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- NIP-44 encryption for secure voucher backup -->
        <dependency>
            <groupId>xyz.tcheeric</groupId>
            <artifactId>wallet-nip-44</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- H2 Database for wallet storage -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- HikariCP for connection pooling -->
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
        </dependency>

        <!-- PostgreSQL for API key persistence -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- Flyway for database migrations -->
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>

        <!-- JDBC for DataSource auto-configuration (required for web UI) -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <!-- Awaitility for async relay operations in NostrProfileAdapter -->
        <!-- Must be compile scope (overrides parent test scope) -->
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>compile</scope>
        </dependency>

        <!-- Thymeleaf for web UI -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity6</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.mockito</groupId>
                    <artifactId>mockito-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.mockito</groupId>
                    <artifactId>mockito-junit-jupiter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <!-- Creates gateway-app-exec.jar for Docker/running -->
                            <!-- Keeps gateway-app.jar as regular JAR for test dependencies -->
                            <classifier>exec</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <configuration>
                    <from>
                        <image>eclipse-temurin:21-jre</image>
                    </from>
                    <to>
                        <image>docker.398ja.xyz/gateway-app</image>
                        <tags>
                            <tag>${project.version}</tag>
                            <tag>latest</tag>
                        </tags>
                    </to>
                    <container>
                        <ports>
                            <port>8081</port>
                        </ports>
                        <jvmFlags>
                            <jvmFlag>-Xms256m</jvmFlag>
                            <jvmFlag>-Xmx512m</jvmFlag>
                        </jvmFlags>
                    </container>
                </configuration>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
