<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <!-- Parent -->
  <parent>
    <groupId>io.stargate</groupId>
    <artifactId>stargate</artifactId>
    <version>2.1.0-BETA-39</version>
  </parent>
  <!-- Artifact properties -->
  <groupId>io.stargate.db.cassandra</groupId>
  <artifactId>persistence-dse-next</artifactId>
  <name>Stargate - Coordinator - Persistence DSE Next</name>
  <properties>
    <!-- If you update this, make sure to keep `cassandra.bundled-driver.version` in sync -->
    <!-- Latest as of 2023-09-14: 4.0.7-0cf63a3d0b6d -->
    <!-- Latest as of 2023-11-13: 4.0.11-49a1eecaf3e4 -->
    <!-- Latest as of 2023-12-05: 4.0.11-b259738f492f -->
    <!-- Latest as of 2024-01-24: 4.0.11-0248d170a615 -->
    <!-- Latest as of 2024-04-29: 4.0.11-591d171ac9c9 -->
    <cassandra.version>4.0.11-591d171ac9c9</cassandra.version>
    <!--
      The driver used internally by cassandra-all for UDFs (must match the version declared in
      cassandra-all's POM).
    -->
    <cassandra.bundled-driver.version>3.11.3</cassandra.bundled-driver.version>
    <!--
      Path to where you have downloaded and compiled datastax/cassandra
    -->
    <ccm.directory>${project.basedir}/../../dse-next/cassandra</ccm.directory>
    <!--
      This actually doesn't affect behavior if ccm.directory is set, but is helpful so that
      log messages aren't misleading. (Otherwise defaults to value set in
      io.stargate.it.storage.ExternalStorage)
    -->
    <ccm.version>dse-next</ccm.version>
  </properties>
  <repositories>
    <repository>
      <id>central</id>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
    <repository>
      <id>artifactory-snapshots</id>
      <url>https://repo.datastax.com/datastax-snapshots-local</url>
    </repository>
    <repository>
      <id>artifactory-releases</id>
      <url>https://repo.datastax.com/datastax-releases-local</url>
    </repository>
    <repository>
      <id>artifactory-dse</id>
      <url>https://repo.datastax.com/artifactory/dse/</url>
    </repository>
  </repositories>
  <dependencies>
    <!-- Stargate component dependencies -->
    <dependency>
      <groupId>io.stargate.db</groupId>
      <artifactId>persistence-api</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.stargate.db</groupId>
      <artifactId>persistence-common</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>io.stargate.core</groupId>
      <artifactId>core</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.stargate.auth</groupId>
      <artifactId>authnz</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Cassandra/DataStax -->
    <dependency>
      <groupId>com.datastax.dse</groupId>
      <artifactId>dse-db-all</artifactId>
      <version>${cassandra.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.gridkit.jvmtool</groupId>
          <artifactId>sjk-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!--
      Redeclare the driver dependency because it's optional in cassandra-all (this is required to
      correctly handle UDFs).
    -->
    <dependency>
      <groupId>com.datastax.cassandra</groupId>
      <artifactId>cassandra-driver-core</artifactId>
      <version>${cassandra.bundled-driver.version}</version>
    </dependency>
    <dependency>
      <groupId>com.datastax.oss</groupId>
      <artifactId>java-driver-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.datastax.oss</groupId>
      <artifactId>java-driver-shaded-guava</artifactId>
      <scope>provided</scope>
    </dependency>
    <!-- 3rd party dependencies -->
    <dependency>
      <groupId>org.immutables</groupId>
      <artifactId>value</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.gridkit.jvmtool</groupId>
      <artifactId>sjk-core</artifactId>
      <version>0.14</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.dropwizard.metrics</groupId>
      <artifactId>metrics-graphite</artifactId>
    </dependency>
    <dependency>
      <groupId>com.github.akarnokd</groupId>
      <artifactId>rxjava2-extensions</artifactId>
      <version>0.20.10</version>
    </dependency>
    <dependency>
      <groupId>org.javatuples</groupId>
      <artifactId>javatuples</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.reactivex.rxjava2</groupId>
      <artifactId>rxjava</artifactId>
      <version>2.2.15</version>
    </dependency>
    <!-- Test dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.stargate.db</groupId>
      <artifactId>persistence-test</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <argLine>${jdk11.module-exports}</argLine>
          <parallel>suites</parallel>
          <threadCountSuites>1</threadCountSuites>
          <reuseForks>false</reuseForks>
          <forkCount>1</forkCount>
          <systemPropertyVariables>
            <ccm.version>${ccm.version}</ccm.version>
            <ccm.directory>${ccm.directory}</ccm.directory>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>${jdk11.module-exports}</argLine>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-sjk</id>
            <phase>compile</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.gridkit.jvmtool</groupId>
                  <artifactId>sjk-core</artifactId>
                  <version>0.14</version>
                  <outputDirectory>${project.build.directory}/sjk-core</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>fix-sjk-core</id>
            <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <!-- Remove root package classes -->
                <delete>
                  <fileset dir="${project.build.directory}/sjk-core/" includes="*.class"/>
                </delete>
                <jar destfile="${project.build.directory}/classes/sjk-core-0.14.jar">
                  <fileset dir="${project.build.directory}/sjk-core"/>
                </jar>
                <delete dir="${project.build.directory}/sjk-core"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <unpackBundle>true</unpackBundle>
          <instructions>
            <Bundle-Name>Cassandra-Persistence</Bundle-Name>
            <Bundle-Description>Cassandra DB component for project</Bundle-Description>
            <Bundle-SymbolicName>io.stargate.db.dse_next</Bundle-SymbolicName>
            <Bundle-Activator>io.stargate.db.cassandra.DseNextPersistenceActivator</Bundle-Activator>
            <Import-Package><![CDATA[
              org.slf4j,
              org.slf4j.helpers,
              org.slf4j.spi,
              ch.qos.logback.classic,
              ch.qos.logback.classic.helpers,
              ch.qos.logback.classic.spi,
              ch.qos.logback.core,
              ch.qos.logback.core.helpers,
              ch.qos.logback.core.spi,
              org.osgi.framework,
              io.stargate.core.*,
              io.stargate.auth.*,
              io.stargate.db,
              io.stargate.db.*,
              org.apache.cassandra.stargate,
              org.apache.cassandra.stargate.*,
              org.javatuples,
              !com.codahale.metrics.graphite.*,
              com.codahale.metrics,
              com.datastax.oss.driver.shaded.guava.common.*,
            ]]></Import-Package>
            <Export-Package>!*</Export-Package>
            <Bundle-ClassPath>.,sjk-core-0.14.jar,{maven-dependencies}</Bundle-ClassPath>
            <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
          <outputDirectory>${project.basedir}/../stargate-lib</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>it-dse-next</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <id>dse-next</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
