<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>
    <groupId>org.cassandraunit</groupId>
    <artifactId>cassandra-unit-parent</artifactId>
    <packaging>pom</packaging>
    <name>cassandra-unit-parent</name>
    <version>5.4.0</version>
    <description>Test data and assertions for Apache Cassandra, with an embedded server if you want one.</description>
    <url>https://github.com/jsevellec/cassandra-unit</url>
    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>Various</name>
            <organization>Various</organization>
        </developer>
    </developers>
    <scm>
        <connection>scm:git:https://github.com/jsevellec/cassandra-unit.git</connection>
        <developerConnection>scm:git:https://github.com/jsevellec/cassandra-unit.git</developerConnection>
        <url>https://github.com/jsevellec/cassandra-unit.git</url>
    <tag>cassandra-unit-parent-5.4.0</tag>
  </scm>
    <modules>
        <module>cassandra-unit-dataset</module>
        <module>cassandra-unit</module>
        <module>cassandra-unit-spring</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>17</maven.compiler.release>

        <cu.junit.version>4.13.2</cu.junit.version>
        <cu.junit.jupiter.version>6.1.3</cu.junit.jupiter.version>
        <cu.assertj.version>3.27.7</cu.assertj.version>
        <cu.cassandra.all.version>5.0.8</cu.cassandra.all.version>
        <cu.cassandra.driver.version>4.19.3</cu.cassandra.driver.version>
        <cu.spring.version>7.0.9</cu.spring.version>
        <!-- Test-scope only, for the @SpringBootTest coverage in cassandra-unit-spring. -->
        <cu.spring.boot.version>4.1.1</cu.spring.boot.version>
        <!-- Must stay compatible with the logback-core the embedded Cassandra brings in -->
        <cu.logback.version>1.5.18</cu.logback.version>

        <!--
          Cassandra 5.0 reaches deep into the JDK, so an embedded daemon needs the same JVM
          flags a real node gets. These are copied verbatim from conf/jvm17-server.options at
          tag cassandra-5.0.8. Consumers of this library must apply the same argLine - see README.

          What is deliberately NOT here is the jamm memory-meter agent, which every previous
          version required as -javaagent plus -Djdk.attach.allowAttachSelf=true, plus a
          maven-dependency-plugin execution to resolve the agent's path. Cassandra asks jamm for a
          fallback chain - ObjectSizes builds MemoryMeter.builder().withGuessing(
          INSTRUMENTATION_AND_SPECIFICATION, UNSAFE) - so with no agent loaded it measures through
          Unsafe instead, which needs no instrumentation and no attach. That drops the most
          error-prone third of the consumer-facing setup: an unresolved ${...} agent path kills the
          fork before surefire can say why. The trade is real but small here: sizes come from Unsafe
          field offsets rather than from instrumentation, which shifts memtable accounting slightly
          in a node that holds a test fixture. The jdk.unsupported/sun.misc export
          below is what that fallback needs, so it stays.
        -->
        <cu.cassandra.argLine>
            -Dio.netty.tryReflectionSetAccessible=true
            --add-exports java.base/jdk.internal.misc=ALL-UNNAMED
            --add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED
            --add-exports java.management/com.sun.jmx.remote.security=ALL-UNNAMED
            --add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED
            --add-exports java.rmi/sun.rmi.server=ALL-UNNAMED
            --add-exports java.sql/java.sql=ALL-UNNAMED
            --add-exports java.base/java.lang.ref=ALL-UNNAMED
            --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED
            --add-opens java.base/java.lang.module=ALL-UNNAMED
            --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
            --add-opens java.base/jdk.internal.ref=ALL-UNNAMED
            --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED
            --add-opens java.base/jdk.internal.math=ALL-UNNAMED
            --add-opens java.base/jdk.internal.module=ALL-UNNAMED
            --add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
            --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
            --add-opens java.base/sun.nio.ch=ALL-UNNAMED
            --add-opens java.base/java.io=ALL-UNNAMED
            --add-opens java.base/java.lang.reflect=ALL-UNNAMED
            --add-opens java.base/java.lang=ALL-UNNAMED
            --add-opens java.base/java.util=ALL-UNNAMED
            --add-opens java.base/java.nio=ALL-UNNAMED
        </cu.cassandra.argLine>
    </properties>

    <!--
      Versions for the three compile dependencies this project declares directly and shares with
      the embedded server. They must match what cassandra-all was built against, or we risk a
      NoSuchMethodError against Cassandra itself - these are the values cassandra-parent 5.0.8
      resolves. Everything else (guava, netty, jackson, logback) arrives transitively from
      cassandra-all at the version its own parent pins, so it does not need managing here.

      Deliberately NOT importing org.apache.cassandra:cassandra-parent as a BOM, even though it
      is where those values come from. The released pom manages
      org.apache.cassandra:cassandra-all to 4.1-alpha2-SNAPSHOT, a version that was never
      published, so importing it broke resolution for any module that picks cassandra-all up
      transitively rather than declaring it - cassandra-unit-spring did. Pinning three versions
      by hand is less fragile than working around that.

      Note for anyone chasing it: the "'dependencies.dependency.systemPath' ... ${jmc5.path}"
      model-validation errors Maven prints are NOT caused by this, and dropping the import does
      not silence them. Maven reads cassandra-parent anyway, as cassandra-all's parent pom, and
      that pom declares system-scoped JMC and VisualVM artifacts with unresolved properties.
      They are noisy but harmless, and only upstream Cassandra can fix them.
    -->
    <dependencyManagement>
        <dependencies>
            <!--
              Patched netty and jackson, ahead of what cassandra-all 5.0.8 pins. Cassandra pins
              netty 4.1.130 and jackson 2.19.2, both of which still carry published advisories;
              these are the nearest fixed versions. netty stays inside 4.1.x, which netty keeps
              binary compatible, and jackson stays inside 2.x. Both are imported as BOMs so the
              whole family moves together rather than mixing versions within netty or jackson.
              Revisit on every cassandra-all upgrade: if Cassandra catches up, delete these.
            -->
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-bom</artifactId>
                <version>4.1.137.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson</groupId>
                <artifactId>jackson-bom</artifactId>
                <version>2.22.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!--
              lz4-java 1.10.1 (what cassandra-all pins) can crash the JVM from invalid byte
              array ranges in its native XXHash path - CVE-2026-59949, fixed in 1.11.1. Same
              deal as netty and jackson above: drop it when Cassandra catches up.
            -->
            <dependency>
                <groupId>at.yawk.lz4</groupId>
                <artifactId>lz4-java</artifactId>
                <version>1.11.2</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.18.0</version>
            </dependency>
            <dependency>
                <groupId>org.yaml</groupId>
                <artifactId>snakeyaml</artifactId>
                <version>2.1</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>2.0.17</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <id>enforce-version-scheme</id>
                        <goals><goal>enforce</goal></goals>
                        <configuration>
                            <rules>
                                <!--
                                  The project version leads with the embedded Cassandra major.
                                  This is checked rather than merely documented because the
                                  project has already shipped a release numbered after the
                                  driver instead: 4.3.1.0 is driver 4.3.1 on Cassandra 3.11.5,
                                  and on 2019-05-09 the scheme flipped mid-flight, releasing
                                  3.11.2.0 and then the same code as 3.7.1.0 seventeen minutes
                                  later - a lower version, which no range could resolve past.
                                  See CONTRIBUTING.md, "Versioning".
                                -->
                                <evaluateBeanshell>
                                    <condition>"${project.version}".split("[.\\-]")[0].equals("${cu.cassandra.all.version}".split("\\.")[0])</condition>
                                    <message>Project version ${project.version} must lead with the embedded Cassandra major (cu.cassandra.all.version is ${cu.cassandra.all.version}). The version number tracks Cassandra, never the driver - see the Versioning section in CONTRIBUTING.md.</message>
                                </evaluateBeanshell>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
            </plugin>

            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.4.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.3</version>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.1.3</version>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <!--
                      Surefire's default includes are Test*, *Test, *Tests and *TestCase. Every
                      CQLDataLoadTestWith* class ends in something else (WithJunitRule,
                      WithFullOptions, ...), so the whole dataset-loading surface - the actual
                      point of this library - was silently never executed by the build.
                    -->
                    <includes>
                        <include>**/*Test*.java</include>
                    </includes>
                    <argLine>-Dfile.encoding=${project.build.sourceEncoding} ${cu.cassandra.argLine}</argLine>
                </configuration>
                <!--
                  Starting Cassandra costs about three seconds, and one Cassandra per JVM is a hard
                  constraint: DatabaseDescriptor / Schema / StorageService hold static state that
                  cannot be reset in-process, so a JVM is pinned to the first configuration it
                  starts. Running every class in its own fork therefore works, but pays that three
                  seconds 22 times.

                  Only a handful of classes actually ask for a non-default configuration. So the
                  suite is split: everything that uses the default cu-cassandra.yaml shares a
                  single JVM and a single Cassandra, and only the classes needing their own
                  configuration get their own fork.
                -->
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <reuseForks>true</reuseForks>
                            <forkCount>1</forkCount>
                            <excludes>
                                <exclude>**/CQLDataLoadTestWithRandomPort.java</exclude>
                                <exclude>**/CQLDataLoadTestWithFullOptions.java</exclude>
                                <exclude>**/EmbeddedCassandraTmpDirTest.java</exclude>
                                <exclude>**/EmbeddedCassandraServerHelperTest.java</exclude>
                                <exclude>**/EmbeddedCassandraServerHelperDefaultsTest.java</exclude>
                                <exclude>**/CQLDataLoadTestWithReadTimeout.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>isolated-config-tests</id>
                        <goals><goal>test</goal></goals>
                        <configuration>
                            <!--
                              Each of these needs a JVM to itself, for one of three reasons:
                                - it starts Cassandra with its own yaml (random ports, relocated
                                  tmpDir), and a JVM is pinned to the first configuration it starts;
                                - EmbeddedCassandraServerHelperDefaultsTest asserts the behaviour of
                                  stopEmbeddedCassandra() when nothing was started, so it must run
                                  where nothing has started - sharing a JVM would make it stop the
                                  server everyone else is using;
                                - CQLDataLoadTestWithReadTimeout asserts the session request
                                  timeout, which is JVM-global and set by whichever test runs first.
                            -->
                            <reuseForks>false</reuseForks>
                            <includes>
                                <include>**/CQLDataLoadTestWithRandomPort.java</include>
                                <include>**/CQLDataLoadTestWithFullOptions.java</include>
                                <include>**/EmbeddedCassandraTmpDirTest.java</include>
                                <include>**/EmbeddedCassandraServerHelperTest.java</include>
                                <include>**/EmbeddedCassandraServerHelperDefaultsTest.java</include>
                                <include>**/CQLDataLoadTestWithReadTimeout.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--
                  Publishing goes through the Central Publisher Portal. The previous setup
                  (distributionManagement pointing at oss.sonatype.org plus
                  nexus-staging-maven-plugin) cannot work any more: OSSRH was sunset and
                  oss.sonatype.org now returns 404, so this project had no working release path
                  at all. Credentials go in settings.xml under the server id below.
                -->
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.11.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>false</autoPublish>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.11.1</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <!--
                                      doclint is the maven-javadoc-plugin 3.x spelling. This was
                                      <additionalparam>-Xdoclint:none</additionalparam>, a 2.x
                                      parameter that 3.x ignores with only a warning - so the
                                      release profile, which nothing in CI exercises, had been
                                      silently failing to build the javadoc jar that Central
                                      requires.
                                    -->
                                    <doclint>none</doclint>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.7</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
