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

    <groupId>com.btb</groupId>
    <artifactId>exchange</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>exchange</name>
    <description>PoC Data of Crypto Exchange</description>

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

        <docker.repo>local</docker.repo>
        <docker.app.tag>latest</docker.app.tag>

        <btb.shared.version>0.0.1-SNAPSHOT</btb.shared.version>
        <xchange.version>5.2.0</xchange.version>
        <testcontainers.version>1.19.8</testcontainers.version>
        <sockjs-client.version>1.5.1</sockjs-client.version>
        <stomp-websocket.version>2.3.4</stomp-websocket.version>
        <bootstrap.version>4.5.3</bootstrap.version>
        <jquery.version>3.7.1</jquery.version>
        <disruptor.version>4.0.0</disruptor.version>
        <curator.version>5.7.0</curator.version>
        <spring-cloud.version>2023.0.2</spring-cloud.version>
        <javamelody.version>2.2.0</javamelody.version>
        <rxjava3.version>3.1.8</rxjava3.version>

        <!-- plugins -->
        <sonar.version>5.0.0.4389</sonar.version>
        <jacoco.version>0.8.12</jacoco.version>
        <surefire.version>3.5.2</surefire.version>
        <code.coverage.exclusions/>
        <aggregate.report.dir>exchange/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
        <dependency-check-maven.version>11.1.0</dependency-check-maven.version>
        <spotless.version>2.43.0</spotless.version>
        <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
        <maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
    </properties>

    <scm>
        <developerConnection>scm:git:https://github.com/buildingsoftwareblocks/exchange.git</developerConnection>
    </scm>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.btb</groupId>
                <artifactId>shared</artifactId>
                <version>${btb.shared.version}</version>
            </dependency>

            <!-- spring boot vs spring cloud https://spring.io/projects/spring-cloud -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- Exclude Spring Boot's -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
            <dependency>
                <groupId>com.lmax</groupId>
                <artifactId>disruptor</artifactId>
                <version>${disruptor.version}</version>
            </dependency>

            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-core</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-binance</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-bitfinex</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-bitflyer</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-bitmex</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-bitstamp</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-btcmarkets</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-cexio</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-coinbasepro</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-coinjar</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-coinmate</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-gemini</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-hitbtc</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-huobi</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-kraken</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-lgo</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-okcoin</artifactId>
                <version>${xchange.version}</version>
            </dependency>
            <dependency>
                <groupId>org.knowm.xchange</groupId>
                <artifactId>xchange-stream-poloniex2</artifactId>
                <version>${xchange.version}</version>
            </dependency>

            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>io.reactivex.rxjava3</groupId>
                <artifactId>rxjava</artifactId>
                <version>${rxjava3.version}</version>
            </dependency>

            <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>sockjs-client</artifactId>
                <version>${sockjs-client.version}</version>
            </dependency>
            <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>stomp-websocket</artifactId>
                <version>${stomp-websocket.version}</version>
            </dependency>
            <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>bootstrap</artifactId>
                <version>${bootstrap.version}</version>
            </dependency>
            <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>jquery</artifactId>
                <version>${jquery.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-framework</artifactId>
                <version>${curator.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.curator</groupId>
                <artifactId>curator-recipes</artifactId>
                <version>${curator.version}</version>
            </dependency>

            <!-- Application monitoring -->
            <dependency>
                <groupId>net.bull.javamelody</groupId>
                <artifactId>javamelody-spring-boot-starter</artifactId>
                <version>${javamelody.version}</version>
            </dependency>

            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>${testcontainers.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>mongodb</artifactId>
                <version>${testcontainers.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>kafka</artifactId>
                <version>${testcontainers.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${testcontainers.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <dependency>
            <groupId>com.lmax</groupId>
            <artifactId>disruptor</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

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

    <modules>
        <module>shared</module>
        <module>config</module>
        <module>frontend</module>
        <module>backend</module>
        <module>analysis</module>
    </modules>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${maven-enforcer-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>enforce-maven</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requireMavenVersion>
                                        <version>3.8.1</version>
                                    </requireMavenVersion>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>${sonar.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire.version}</version>
                </plugin>

                <plugin>
                    <groupId>org.owasp</groupId>
                    <artifactId>dependency-check-maven</artifactId>
                    <version>${dependency-check-maven.version}</version>
                    <configuration>
                        <suppressionFiles>
                            <suppressionFile>owasp-project-suppression.xml</suppressionFile>
                        </suppressionFiles>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.btb</groupId>
                            <artifactId>shared</artifactId>
                            <version>${btb.shared.version}</version>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <id>check-dependencies</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>${maven-release-plugin.version}</version>
                </plugin>

                <plugin>
                    <groupId>com.diffplug.spotless</groupId>
                    <artifactId>spotless-maven-plugin</artifactId>
                    <version>${spotless.version}</version>
                    <configuration>
                        <java>
                            <palantirJavaFormat>
                                <style>PALANTIR</style>
                                <version>2.38.0</version>
                            </palantirJavaFormat>
                        </java>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>apply</goal>
                            </goals>
                            <phase>process-sources</phase>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <!-- Add GIT info to /actuator/info -->
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>docker</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <image>
                                <name>${docker.repo}/exchange-${project.artifactId}</name>
                                <publish>false</publish>
                                <tags>
                                    <tag>latest</tag>
                                    <tag>git-${git.commit.id.abbrev}</tag>
                                </tags>
                            </image>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-image</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>coverage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <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>
        </profile>

        <profile>
            <id>sonar</id>
            <properties>
                <sonar.host.url>https://sonarcloud.io</sonar.host.url>
                <sonar.organization>buildingsoftwareblocks</sonar.organization>
                <sonar.projectKey>buildingsoftwareblocks_exchange</sonar.projectKey>
                <sonar.moduleKey>${project.groupId}:${project.artifactId}</sonar.moduleKey>
                <sonar.exclusions>${code.coverage.exclusions}</sonar.exclusions>
                <sonar.report>${aggregate.report.dir}</sonar.report>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sonar</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sonar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.owasp</groupId>
                        <artifactId>dependency-check-maven</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>formatter</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>owasp</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.owasp</groupId>
                        <artifactId>dependency-check-maven</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>