<?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.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>ru.nbch</groupId>
    <artifactId>indic-search-service</artifactId>
    <version>0.0.1</version>
    <name>indic-search-service</name>
    <description>indic-search-service</description>

    <properties>
        <java.version>21</java.version>

        <registry.url>10.230.238.56:5000</registry.url>
<!--        <registry.url>nexus-dev.nbki.msk</registry.url>-->
<!--        <registry.url>rh8-vm3.nbki.msk:5000</registry.url>-->

        <mybatis-spring.version>4.0.1</mybatis-spring.version>
        <springdoc-openapi.version>3.0.3</springdoc-openapi.version>
        <apm-agent-api.version>1.55.6</apm-agent-api.version>
        <logstash-logback-encoder.version>9.0</logstash-logback-encoder.version>
        <poi.version>5.5.1</poi.version>
        <docker-maven-plugin.version>0.48.1</docker-maven-plugin.version>
    </properties>

    <dependencies>
        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webmvc</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-aspectj</artifactId>
        </dependency>

        <!-- Database -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>${mybatis-spring.version}</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.ibm.db2</groupId>
            <artifactId>jcc</artifactId>
            <scope>runtime</scope>
        </dependency>

        <!-- OpenAPI -->
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>${springdoc-openapi.version}</version>
        </dependency>

        <!-- APM -->
        <dependency>
            <groupId>co.elastic.apm</groupId>
            <artifactId>apm-agent-api</artifactId>
            <version>${apm-agent-api.version}</version>
        </dependency>
        <dependency>
            <groupId>net.logstash.logback</groupId>
            <artifactId>logstash-logback-encoder</artifactId>
            <version>${logstash-logback-encoder.version}</version>
        </dependency>

        <!-- XLSX documents -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${poi.version}</version>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webmvc-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter-test</artifactId>
            <version>${mybatis-spring.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>application.properties</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>
                        @{argLine}
                        -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar
                        -Xshare:off
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.14</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>with-docker-registry</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>${docker-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>build</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>build</goal>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
<!--                             todo: For nexus, waiting for access -->
<!--                                <authConfig>-->
<!--                                    &lt;!&ndash;suppress UnresolvedMavenProperty &ndash;&gt;-->
<!--                                    <username>${env.NEXUS_USERNAME}</username>-->
<!--                                    &lt;!&ndash;suppress UnresolvedMavenProperty &ndash;&gt;-->
<!--                                    <password>${env.NEXUS_PASSWORD}</password>-->
<!--                                </authConfig>-->
                            <images>
                                <image>
                                    <name>${registry.url}/${project.name}:${project.version}</name>
                                    <registry>${registry.url}</registry>
                                    <build>
                                        <dockerFile>${project.basedir}/Dockerfile</dockerFile>
                                        <assembly>
                                            <inline>
                                                <files>
                                                    <file>
                                                        <source>
                                                            ${project.basedir}/apm-agent/elastic-apm-agent-1.50.0.jar
                                                        </source>
                                                        <outputDirectory>.</outputDirectory>
                                                    </file>
                                                    <file>
                                                        <source>
                                                            ${project.build.directory}/${project.build.finalName}.jar
                                                        </source>
                                                        <outputDirectory>.</outputDirectory>
                                                    </file>
                                                    <file>
                                                        <source>
                                                            ${project.basedir}/src/main/resources/application.properties
                                                        </source>
                                                        <outputDirectory>.</outputDirectory>
                                                    </file>
                                                </files>
                                            </inline>
                                        </assembly>
                                        <tags>
                                            <tag>${project.version}</tag>
                                        </tags>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>mfd</id>
            <name>mfd</name>
            <url>http://10.200.200.131:8888/repository/internal/</url>
        </repository>
    </repositories>

</project>
