<?xml version="1.0"?>
<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">
  <parent>
    <groupId>io.debezium</groupId>
    <artifactId>debezium-parent</artifactId>
    <version>3.0.8.Final-redhat-00004</version>
    <relativePath>../debezium-parent/pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>debezium-connect-rest-extension</artifactId>
  <name>Debezium Kafka Connect REST Extension</name>

  <properties>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.compiler.parameters>true</maven.compiler.parameters>

    <!-- Assembly configuration -->
    <assembly.descriptor>rest-distribution</assembly.descriptor>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.debezium</groupId>
      <artifactId>debezium-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.kafka</groupId>
      <artifactId>connect-runtime</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>org.apache.kafka</groupId>
          <artifactId>kafka-log4j-appender</artifactId>
        </exclusion>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.debezium</groupId>
      <artifactId>debezium-testing-testcontainers</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>kafka</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
            <configuration>
              <skipTests>${skipITs}</skipTests>
              <enableAssertions>true</enableAssertions>
              <systemPropertyVariables>
                <skipLongRunningTests>${skipLongRunningTests}</skipLongRunningTests>
                <maven.home>${maven.home}</maven.home>
              </systemPropertyVariables>
              <runOrder>${runOrder}</runOrder>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <resources>
      <!-- Apply the properties set in the POM to the resource files -->
      <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
        <includes>
          <include>*</include>
          <include>**/*</include>
        </includes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>*</include>
          <include>**/*</include>
        </includes>
      </testResource>
    </testResources>
  </build>

  <profiles>
    <profile>
      <id>assembly</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>${version.assembly.plugin}</version>
            <dependencies>
              <dependency>
                <groupId>io.debezium</groupId>
                <artifactId>debezium-assembly-descriptors</artifactId>
                <version>${project.version}</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>default</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <appendAssemblyId>false</appendAssemblyId>
                  <finalName>${project.artifactId}-${project.version}</finalName>
                  <attach>true</attach>  <!-- we want attach & deploy these to Maven -->
                  <descriptorRefs>
                    <descriptorRef>${assembly.descriptor}</descriptorRef>
                  </descriptorRefs>
                  <tarLongFileMode>posix</tarLongFileMode>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <configuration>
              <executable>tar</executable>
              <workingDirectory>${project.build.directory}</workingDirectory>
            </configuration>
            <executions>
              <execution>
                <id>extract-assembly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <arguments>
                    <argument>-xf</argument>
                    <argument>${project.artifactId}-${project.version}.tar.gz</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>quick</id>
      <activation>
        <property>
          <name>quick</name>
        </property>
      </activation>
      <properties>
        <skipITs>true</skipITs>
      </properties>
    </profile>
    <profile>
      <id>skip-integration-tests</id>
      <activation>
        <property>
          <name>skipITs</name>
        </property>
      </activation>
    </profile>
  </profiles>

</project>
