<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.cassandraunit</groupId>
        <artifactId>cassandra-unit-parent</artifactId>
        <version>5.4.0</version>
    </parent>
    <groupId>org.cassandraunit</groupId>
    <artifactId>cassandra-unit-dataset</artifactId>
    <name>cassandra-unit-dataset</name>
    <description>Load CQL and YAML/JSON/XML/CSV test data into any Cassandra, through a CqlSession you supply</description>

    <!--
      The fixture layer, with no embedded server.

      Everything here talks to a CqlSession the caller hands it, so it works against whatever the
      caller already has: a Testcontainers node, a local Cassandra, ScyllaDB, Astra. That means it
      needs the driver and three parsers and nothing else - no cassandra-all, no jamm agent, and
      none of the add-opens/add-exports set that cassandra-unit's consumers must configure.

      It also has no JDK ceiling. The embedded module is pinned to exactly 17, and can never run on
      24+ because Cassandra's ThreadAwareSecurityManager calls System::setSecurityManager. This one
      compiles to 17 and runs on any later JDK.

      cassandra-unit depends on this at compile scope, so everything here stays on the classpath of
      anyone who depends on cassandra-unit and nobody has to change an import.
    -->

    <dependencies>
        <dependency>
            <groupId>org.apache.cassandra</groupId>
            <artifactId>java-driver-core</artifactId>
            <version>${cu.cassandra.driver.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <!--
          CSV is the only format needing a dependency the driver does not already drag in, and most
          datasets are not CSV. Optional keeps it off everyone else's classpath; CQLDataSetFactory
          probes for it and explains what to add if a .csv is loaded without it.
        -->
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-csv</artifactId>
            <optional>true</optional>
        </dependency>

        <!--
          For CqlDataSetExtension and the assertion integrations. Both JUnits are optional, for the
          reason cassandra-unit declares them so: a consumer brings their own test framework, and
          this module must not put one on their classpath. Anyone not using a given integration
          never loads its class.
        -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${cu.junit.jupiter.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${cu.junit.version}</version>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${cu.junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <!--
          Optional, not test-scoped, because org.cassandraunit.assertion.CqlAssertions and the
          assert types around it extend AssertJ's AbstractAssert - that inheritance is what buys
          as(), satisfies() and SoftAssertions, and it has to be on the compile classpath.

          Optional keeps the promise that made this acceptable: an optional dependency is never
          transitive, so nobody who does not ask for AssertJ resolves it, exactly as with
          jackson-dataformat-csv and the two JUnits above. Nothing else in this module touches it,
          so a consumer who never imports CqlAssertions is unaffected. One that does and has no
          assertj-core gets NoClassDefFoundError on AbstractAssert; unlike the CSV parser there is
          no constructor to intercept and turn into a message naming the coordinates.
        -->
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${cu.assertj.version}</version>
            <optional>true</optional>
        </dependency>

        <!--
          For org.cassandraunit.SpringSessions, which hands CqlDataSetExtension the CqlSession bean
          out of a Spring test's ApplicationContext. spring-test carries SpringExtension, whose
          getApplicationContext is the entry point; spring-context carries ApplicationContext
          itself, and spring-test does not depend on it - its only non-optional dependency is
          spring-core - so both have to be named here.

          Optional, like the two JUnits and AssertJ above and for the same reason: an optional
          dependency is never transitive, so a consumer who never imports SpringSessions never
          resolves Spring. Nothing else in this module references it.

          Note there is no requireJavaVersion rule in this module and this does not add one.
          Compiling against Spring's JDK 17 class files on a newer JDK is fine, which is what the
          dataset-on-newer-jdks CI job checks.
        -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${cu.spring.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${cu.spring.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${cu.logback.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${cu.logback.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>org.cassandraunit.dataset</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <!--
                      There is deliberately no requireJavaVersion rule here. cassandra-unit and
                      cassandra-unit-spring each carry one pinning JDK 17, because the embedded
                      daemon runs in the build JVM and Cassandra 5.0 supports nothing else. This
                      module starts no daemon, so it has no upper bound - and the CI job that
                      builds it on a later JDK is the demonstration of that.
                    -->

                    <!--
                      The whole claim of this artifact, checked rather than asserted. If any of
                      these ever appears in the tree, the JPMS flags and the JDK ceiling come back
                      with it and consumers find out at runtime instead of here.
                    -->
                    <execution>
                        <id>no-embedded-server-on-the-classpath</id>
                        <goals><goal>enforce</goal></goals>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <searchTransitive>true</searchTransitive>
                                    <excludes>
                                        <exclude>org.apache.cassandra:cassandra-all</exclude>
                                        <exclude>org.apache.cassandra:cassandra-thrift</exclude>
                                        <exclude>com.github.jbellis:jamm</exclude>
                                    </excludes>
                                    <message>cassandra-unit-dataset must resolve without the embedded server. Something has pulled cassandra-all (or the jamm agent) onto its classpath, which would drag the JPMS --add-opens set and the JDK 17-only ceiling along with it. That is exactly what this artifact exists to avoid.</message>
                                </bannedDependencies>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!--
                      A plain JVM: no add-opens, no add-exports.

                      This is not a tidy-up, it is the artifact's central claim expressed in the
                      build. The parent's ${cu.cassandra.argLine} is 23 lines of JPMS flags that
                      exist only so an embedded Cassandra daemon can reach into the JDK. That these
                      tests pass without any of it is the standing proof that the fixture code needs
                      no embedded server.
                    -->
                    <argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
                </configuration>
                <executions>
                    <!-- Nothing here needs its own Cassandra configuration; there is no Cassandra. -->
                    <execution>
                        <id>isolated-config-tests</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
