<?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>
    <groupId>com.katanox</groupId>
    <artifactId>tabour</artifactId>
    <version>0.1.2</version>
    <name>Tabour</name>
    <url>https://github.com/katanox/tabour</url>
    <description>Kotlin's library to make working with queues/topics much easier.</description>
    <repositories>
        <repository>
            <id>jcenter</id>
            <name>jcenter</name>
            <url>https://jcenter.bintray.com</url>
        </repository>
    </repositories>
    <licenses>
        <license>
            <name>The Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>Ahmad Shabib</name>
            <email>a.shabib@katanox.com</email>
            <organization>Katanox</organization>
            <organizationUrl>http://www.katanox.com</organizationUrl>
        </developer>
    </developers>
    <scm>
        <connection>scm:git:git://github.com/katanox/tabour.git</connection>
        <developerConnection>scm:git:git@github.com:katanox/tabour.git</developerConnection>
        <url>https://github.com/katanox/tabour</url>
    </scm>
    <properties>
        <skipTests>false</skipTests>
        <skipITs>${skipTests}</skipITs>
        <skipUTs>${skipTests}</skipUTs>

        <!-- language dependencies -->
        <java.version>11</java.version>
        <kotlin.version>1.4.31</kotlin.version>

        <!-- plugins -->
        <resources.plugin.version>3.0.2</resources.plugin.version>
        <sunfire.plugin.version>3.0.0-M5</sunfire.plugin.version>
        <jacoco.plugin.version>0.8.5</jacoco.plugin.version>
        <failsafe.plugin.version>2.22.1</failsafe.plugin.version>
        <compiler.plugin.version>3.8.1</compiler.plugin.version>
        <source.plugin.version>3.2.1</source.plugin.version>
        <helper.plugin.version>3.2.0</helper.plugin.version>
        <directory.plugin.version>0.3.1</directory.plugin.version>

        <!-- third party dependencies -->
        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
        <gson.version>2.8.6</gson.version>
        <!-- https://mvnrepository.com/artifact/io.kotest/kotest-assertions-core-jvm -->
        <kotest.version>4.4.3</kotest.version>
        <!-- https://mvnrepository.com/artifact/org.testcontainers/testcontainers -->
        <testcontainers.version>1.15.2</testcontainers.version>
        <!-- https://mvnrepository.com/artifact/org.testcontainers/junit-jupiter -->
        <testcontainers.jupiter.version>1.15.2</testcontainers.jupiter.version>
        <!-- https://mvnrepository.com/artifact/io.github.microutils/kotlin-logging-jvm -->
        <kotlin-jvm-logging.version>2.0.6</kotlin-jvm-logging.version>
        <!-- https://mvnrepository.com/artifact/io.mockk/mockk -->
        <mockk.version>1.11.0</mockk.version>
        <spring.boot.version>2.5.0</spring.boot.version>
        <spring.cloud.version>2.2.6.RELEASE</spring.cloud.version>
        <javax.annotation.version>1.3.2</javax.annotation.version>
        <resilience4j.retry.version>1.6.1</resilience4j.retry.version>
        <jetbrains.kotlin.version>1.5.10</jetbrains.kotlin.version>
        <kotlin.coroutines.version>1.5.0</kotlin.coroutines.version>
        <aws-java-sdk.version>1.12.11</aws-java-sdk.version>
        <protobuf-java-util.version>3.17.3</protobuf-java-util.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-bom</artifactId>
                <version>${aws-java-sdk.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>${javax.annotation.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-aws-messaging</artifactId>
            <version>${spring.cloud.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-retry</artifactId>
            <version>${resilience4j.retry.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
            <version>${jetbrains.kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${jetbrains.kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-core</artifactId>
            <version>${kotlin.coroutines.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.microutils</groupId>
            <artifactId>kotlin-logging-jvm</artifactId>
            <version>${kotlin-jvm-logging.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
            <version>${protobuf-java-util.version}</version>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>io.mockk</groupId>
            <artifactId>mockk</artifactId>
            <version>${mockk.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.kotest</groupId>
            <artifactId>kotest-assertions-core-jvm</artifactId>
            <version>${kotest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${testcontainers.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <artifactId>kotlin-test-junit</artifactId>
            <groupId>org.jetbrains.kotlin</groupId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.7.0</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <configuration>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>spring</plugin>
                        <plugin>jpa</plugin>
                    </compilerPlugins>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-allopen</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-noarg</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <phase>test-compile</phase>
                        <configuration>
                            <testOutput>${basedir}/target/test-classes</testOutput>
                            <sourceDirs>
                                <source>src/test/kotlin</source>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile-integration-tests</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <testOutput>${basedir}/target/integration-test-classes</testOutput>
                            <sourceDirs>
                                <sourceDir>
                                    ${basedir}/src/integration-test/kotlin
                                </sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <source>src/main/kotlin</source>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${resources.plugin.version}</version>
                <executions>
                    <execution>
                        <id>default-testResources</id>
                        <goals>
                            <goal>testResources</goal>
                        </goals>
                        <phase>process-test-resources</phase>
                        <configuration>
                            <outputDirectory>${basedir}/target/test-classes</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/test/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-integration-test-resources</id>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <outputDirectory>${basedir}/target/integration-test-classes</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/integration-test/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${sunfire.plugin.version}</version>
                <configuration>
                    <testClassesDirectory>${basedir}/target/test-classes</testClassesDirectory>
                    <testSourceDirectory>${basedir}/src/test/kotlin</testSourceDirectory>
                    <argLine>${surefireArgLine}</argLine>
                    <testFailureIgnore>false</testFailureIgnore>
                    <skipTests>${skipUTs}</skipTests>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.plugin.version}</version>
                <configuration>
                    <excludes>
                        <exclude>**/model/**</exclude>
                    </excludes>
                    <destFile>${basedir}/target/coverage-reports/jacoco.exec</destFile>
                    <dataFile>${basedir}/target/coverage-reports/jacoco.exec</dataFile>
                    <outputDirectory>${basedir}/target/site/jacoco</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                        </configuration>
                    </execution>

                    <execution>
                        <id>pre-integration-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
                            <propertyName>failsafeArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${failsafe.plugin.version}</version>
                <configuration>
                    <reuseForks>true</reuseForks>
                    <argLine>${failsafeArgLine}</argLine>
                    <skipTests>${skipTests}</skipTests>
                    <skipITs>${skipITs}</skipITs>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/**</include>
                            </includes>
                            <classesDirectory>${project.build.outputDirectory}</classesDirectory>
                            <testClassesDirectory>${basedir}/target/integration-test-classes</testClassesDirectory>
                            <testSourceDirectory>${basedir}/src/integration-test/kotlin</testSourceDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <testFailureIgnore>false</testFailureIgnore>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler.plugin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>testCompile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${source.plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${helper.plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-empty-javadoc</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${basedir}/lib/empty-javadoc.jar</file>
                                    <type>jar</type>
                                    <classifier>javadoc</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.commonjava.maven.plugins</groupId>
                <artifactId>directory-maven-plugin</artifactId>
                <version>${directory.plugin.version}</version>
                <executions>
                    <execution>
                        <id>directories</id>
                        <goals>
                            <goal>highest-basedir</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <property>highest-basedir</property>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.2.0</version>
            </plugin>
        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>central-deployment</id>
            <distributionManagement>
                <repository>
                    <id>ossrh</id>
                    <name>Maven Central</name>
                    <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
                <snapshotRepository>
                    <id>ossrh</id>
                    <name>Maven Central Snapshots</name>
                    <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>github-deployment</id>
            <distributionManagement>
                <repository>
                    <id>github</id>
                    <name>GitHub Packages</name>
                    <url>https://maven.pkg.github.com/katanox/tabour</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

</project>
