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

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>4.0.3</version>
        <relativePath/>
    </parent>

    <groupId>com.petshop</groupId>
    <artifactId>backend</artifactId>
    <version>1.0.0</version>
    <name>PetShop Backend</name>
    <description>Spring Boot backend for PetShop desktop application</description>

    <properties>
        <java.version>25</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</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-validation</artifactId>
        </dependency>

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

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-mysql</artifactId>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-api</artifactId>
            <version>0.12.3</version>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-impl</artifactId>
            <version>0.12.3</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt-jackson</artifactId>
            <version>0.12.3</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>3.0.1</version>
        </dependency>

        <dependency>
            <groupId>com.stripe</groupId>
            <artifactId>stripe-java</artifactId>
            <version>25.3.0</version>
        </dependency>

        <dependency>
            <groupId>com.resend</groupId>
            <artifactId>resend-java</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <release>25</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <id>require-java-25</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>[25,)</version>
                                    <message>JDK 25 or newer is required. Configure IntelliJ and Maven to use JDK 25 before running the backend.</message>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>dev-stack</id>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.petshop.backend.DevStackApplication</mainClass>
                            <classpathScope>runtime</classpathScope>
                            <systemProperties>
                                <systemProperty>
                                    <key>UPLOAD_BASE_DIR</key>
                                    <value>${project.basedir}/uploads</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>
                    </execution>
                    <execution>
                        <id>reset-db</id>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.petshop.backend.ResetDatabaseApplication</mainClass>
                            <classpathScope>runtime</classpathScope>
                            <arguments>
                                <argument>clean</argument>
                                <argument>install</argument>
                                <argument>-DskipTests</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>docker-up</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>docker-compose.dev.yml</argument>
                                <argument>up</argument>
                                <argument>-d</argument>
                                <argument>--wait</argument>
                                <argument>db</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>docker-down</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>docker-compose.dev.yml</argument>
                                <argument>down</argument>
                                <argument>-v</argument>
                                <argument>--remove-orphans</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>docker-up-target-db</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>docker-compose.target-db.yml</argument>
                                <argument>up</argument>
                                <argument>-d</argument>
                                <argument>--wait</argument>
                                <argument>db-target</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>docker-down-target-db</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>docker-compose.target-db.yml</argument>
                                <argument>down</argument>
                                <argument>-v</argument>
                                <argument>--remove-orphans</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>docker-logs-target-db</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>docker</executable>
                            <arguments>
                                <argument>compose</argument>
                                <argument>-f</argument>
                                <argument>docker-compose.target-db.yml</argument>
                                <argument>logs</argument>
                                <argument>db-target</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
