<?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>dev.streamx</groupId>
  <artifactId>ingestion-client</artifactId>
  <version>1.0.2</version>
  <name>StreamX : Clients :: Ingestion Client</name>

  <distributionManagement>
    <repository>
      <id>streamx-maven-public-releases</id>
      <url>artifactregistry://europe-west1-maven.pkg.dev/streamx-releases/streamx-maven-public-releases</url>
    </repository>
    <snapshotRepository>
      <id>streamx-maven-snapshots</id>
      <url>artifactregistry://europe-west1-maven.pkg.dev/streamx-releases/streamx-maven-snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <properties>
    <!-- Target java version is set to 8 to support older platforms -->
    <maven.compiler.target>8</maven.compiler.target>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.release>8</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <failsafe-plugin.version>${surefire-plugin.version}</failsafe-plugin.version>
    <surefire-plugin.version>3.1.2</surefire-plugin.version>
    <checkstyle-plugin.version>3.2.0</checkstyle-plugin.version>
    <jacoco-plugin.version>0.8.11</jacoco-plugin.version>
    <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
    <sortpom-maven-plugin.version>3.4.0</sortpom-maven-plugin.version>
    <build-helper-maven-plugin.version>3.6.0</build-helper-maven-plugin.version>
    <bnd.version>7.0.0</bnd.version>
    <httpclient.version>4.5.14</httpclient.version>
    <avro.version>1.11.3</avro.version>
    <jackson-core.version>2.16.1</jackson-core.version>
    <slf4j-api.version>2.0.12</slf4j-api.version>
    <org.osgi.annotation.versioning.version>1.1.2</org.osgi.annotation.versioning.version>
    <junit-jupiter.version>5.10.1</junit-jupiter.version>
    <assertj-core.version>3.24.2</assertj-core.version>
    <wiremock.version>3.3.1</wiremock.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>${httpclient.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.avro</groupId>
      <artifactId>avro</artifactId>
      <version>${avro.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson-core.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j-api.version}</version>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.annotation.versioning</artifactId>
      <version>${org.osgi.annotation.versioning.version}</version>
    </dependency>

    <!--  Test dependencies  -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${assertj-core.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.wiremock</groupId>
      <artifactId>wiremock</artifactId>
      <version>${wiremock.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${checkstyle-plugin.version}</version>
        <configuration>
          <configLocation>google_checks.xml</configLocation>
          <failsOnError>true</failsOnError>
          <consoleOutput>true</consoleOutput>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
          <failOnViolation>true</failOnViolation>
          <violationSeverity>warning</violationSeverity>
          <logViolationsToConsole>true</logViolationsToConsole>
          <suppressionsLocation>../../codestyle/checkstyle-suppressions.xml</suppressionsLocation>
          <sourceDirectories>
            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
            <sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
          </sourceDirectories>
        </configuration>
        <executions>
          <execution>
            <id>checkstyle</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco-plugin.version}</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>generate-report</id>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
          <execution>
            <id>perform-coverage-check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <rules>
                <rule>
                  <element>BUNDLE</element>
                  <limits>
                    <limit>
                      <counter>INSTRUCTION</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>75%</minimum>
                    </limit>
                  </limits>
                </rule>
              </rules>
            </configuration>
          </execution>
          <execution>
            <id>perform-complexity-check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <rules>
                <rule>
                  <element>CLASS</element>
                  <limits>
                    <limit>
                      <counter>COMPLEXITY</counter>
                      <value>TOTALCOUNT</value>
                      <maximum>20</maximum>
                    </limit>
                  </limits>
                </rule>
                <rule>
                  <element>METHOD</element>
                  <limits>
                    <limit>
                      <counter>COMPLEXITY</counter>
                      <value>TOTALCOUNT</value>
                      <maximum>5</maximum>
                    </limit>
                  </limits>
                </rule>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bnd-maven-plugin</artifactId>
        <version>${bnd.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>bnd-process</id>
            <goals>
              <goal>bnd-process</goal>
            </goals>
          </execution>
          <execution>
            <id>jar</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bnd-baseline-maven-plugin</artifactId>
        <version>${bnd.version}</version>
        <!-- TODO enable after LTS release 1.0.0 to start validation of packages versions -->
        <configuration>
          <skip>true</skip>
        </configuration>
        <executions>
          <execution>
            <id>baseline</id>
            <goals>
              <goal>baseline</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc-plugin.version}</version>
        <configuration>
          <excludePackageNames>
            dev.streamx.clients.ingestion.impl;
            dev.streamx.clients.ingestion.impl.utils;
            dev.streamx.clients.ingestion.model.generated;
          </excludePackageNames>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>jar</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <failOnWarnings>true</failOnWarnings>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.github.ekryd.sortpom</groupId>
        <artifactId>sortpom-maven-plugin</artifactId>
        <version>${sortpom-maven-plugin.version}</version>
        <configuration>
          <verifyFail>Stop</verifyFail>
          <createBackupFile>false</createBackupFile>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro-maven-plugin</artifactId>
        <version>${avro.version}</version>
        <executions>
          <execution>
            <id>generate-avro-test-model-sources</id>
            <goals>
              <goal>schema</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <sourceDirectory>${project.basedir}/src/test/resources/avro/</sourceDirectory>
              <outputDirectory>${project.build.directory}/generated-test-sources/</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>add-generated-test-sources</id>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-test-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
