<?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>
        <groupId>org.lance</groupId>
        <artifactId>lance-trino-root</artifactId>
        <version>0.3.2</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>lance-trino</artifactId>
    <packaging>trino-plugin</packaging>
    <name>${project.artifactId}</name>
    <description>Trino - Lance connector</description>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>
        <!-- Default to 1C (1 per CPU). Override via -Dsurefire.forkCount for constrained machines. -->
        <surefire.forkCount>1C</surefire.forkCount>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>bootstrap</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>configuration</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>json</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>log</artifactId>
        </dependency>

        <dependency>
            <groupId>io.substrait</groupId>
            <artifactId>core</artifactId>
            <version>0.40.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <!-- Avoid conflicts with Trino's jackson and snakeyaml versions -->
                <exclusion>
                    <groupId>com.fasterxml.jackson.dataformat</groupId>
                    <artifactId>jackson-dataformat-yaml</artifactId>
                </exclusion>
                <!-- Use Trino's managed protobuf version -->
                <exclusion>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-cache</artifactId>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-plugin-toolkit</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
        </dependency>

        <!-- other dependencies -->
        <dependency>
            <groupId>org.apache.arrow</groupId>
            <artifactId>arrow-memory-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.arrow</groupId>
            <artifactId>arrow-vector</artifactId>
        </dependency>

        <dependency>
            <groupId>org.lance</groupId>
            <artifactId>lance-core</artifactId>
            <version>7.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.jupiter</groupId>
                    <artifactId>junit-jupiter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.lance</groupId>
            <artifactId>lance-namespace-apache-client</artifactId>
            <version>0.7.7</version>
        </dependency>

        <dependency>
            <groupId>org.lance</groupId>
            <artifactId>lance-namespace-core</artifactId>
            <version>0.7.7</version>
        </dependency>

        <dependency>
            <groupId>org.weakref</groupId>
            <artifactId>jmxutils</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>slice</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-context</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-spi</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.openjdk.jol</groupId>
            <artifactId>jol-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>log-manager</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <version>2.1.3</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.16</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>configuration-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>junit-extensions</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-main</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-main</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-spi</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-testing-kafka</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.jersey.core</groupId>
                    <artifactId>jersey-common</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.trino</groupId>
            <artifactId>trino-tpch</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.trino.tpch</groupId>
            <artifactId>tpch</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>kafka</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>localstack</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>auth</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>aws-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>regions</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>sdk-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <configuration>
                    <rules>
                        <requireUpperBoundDeps>
                            <excludes combine.children="append">
                                <exclude>org.apache.thrift:libthrift</exclude>
                                <exclude>io.netty:netty</exclude>
                                <!-- lance-core brings newer versions -->
                                <exclude>org.apache.commons:commons-lang3</exclude>
                                <exclude>com.google.guava:failureaccess</exclude>
                                <exclude>org.apache.logging.log4j:log4j-api</exclude>
                                <!-- arrow dependencies managed by trino but lance-core brings different versions -->
                                <exclude>org.apache.arrow:arrow-dataset</exclude>
                                <exclude>org.apache.arrow:arrow-memory-netty</exclude>
                                <exclude>org.apache.arrow:arrow-vector</exclude>
                                <exclude>org.apache.arrow:arrow-c-data</exclude>
                                <!-- substrait-java jackson dependencies bring newer snakeyaml -->
                                <exclude>org.yaml:snakeyaml</exclude>
                            </excludes>
                        </requireUpperBoundDeps>
                        <enforceBytecodeVersion>
                            <excludes combine.children="append">
                                <!-- Trino SPI compiled with Java 24 -->
                                <exclude>io.trino:trino-spi</exclude>
                                <exclude>io.trino:trino-matching</exclude>
                                <exclude>io.trino:trino-cache</exclude>
                                <exclude>io.trino:trino-plugin-toolkit</exclude>
                            </excludes>
                        </enforceBytecodeVersion>
                    </rules>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>--add-opens=java.base/java.nio=ALL-UNNAMED</argLine>
                    <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" />
                    <useSystemClassLoader>false</useSystemClassLoader>
                    <!-- Each DistributedQueryRunner consumes ~500 threads. Limit parallel forks to
                         avoid exhausting the OS thread limit (ulimit -u). The Makefile computes a
                         safe value for the local machine and passes it via -Dsurefire.forkCount. -->
                    <forkCount>${surefire.forkCount}</forkCount>
                    <systemPropertyVariables>
                        <junit.jupiter.execution.parallel.mode.classes.default>same_thread</junit.jupiter.execution.parallel.mode.classes.default>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <configuration>
                    <ignoredUnusedDeclaredDependencies combine.children="append">
                        <!-- Required at compile time for substrait Expression class hierarchy -->
                        <ignoredUnusedDeclaredDependency>com.google.protobuf:protobuf-java</ignoredUnusedDeclaredDependency>
                        <!-- Currently unused but kept for potential future use -->
                        <ignoredUnusedDeclaredDependency>io.trino:trino-cache</ignoredUnusedDeclaredDependency>
                        <!-- Used for @SuppressModernizer annotation -->
                        <ignoredUnusedDeclaredDependency>org.gaul:modernizer-maven-annotations</ignoredUnusedDeclaredDependency>
                    </ignoredUnusedDeclaredDependencies>
                    <ignoredUsedUndeclaredDependencies>
                        <!-- Provided transitively by the parent pom -->
                        <ignoredUsedUndeclaredDependency>org.gaul:modernizer-maven-annotations</ignoredUsedUndeclaredDependency>
                    </ignoredUsedUndeclaredDependencies>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.basepom.maven</groupId>
                <artifactId>duplicate-finder-maven-plugin</artifactId>
                <configuration>
                    <ignoredDependencies>
                        <dependency>
                            <groupId>io.netty</groupId>
                            <artifactId>netty-transport-classes-epoll</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>io.netty</groupId>
                            <artifactId>netty-transport-native-epoll</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>jakarta.validation</groupId>
                            <artifactId>jakarta.validation-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>javax.validation</groupId>
                            <artifactId>validation-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-c-data</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-dataset</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-format</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-memory-core</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-memory-netty-buffer-patch</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-memory-netty</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.arrow</groupId>
                            <artifactId>arrow-vector</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.helix</groupId>
                            <artifactId>helix-common</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.helix</groupId>
                            <artifactId>helix-core</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.helix</groupId>
                            <artifactId>metrics-common</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.helix</groupId>
                            <artifactId>metadata-store-directory-common</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.helix</groupId>
                            <artifactId>zookeeper-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>commons-logging</groupId>
                            <artifactId>commons-logging</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.slf4j</groupId>
                            <artifactId>jcl-over-slf4j</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.apache.logging.log4j</groupId>
                            <artifactId>log4j-slf4j-impl:2.17.1</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.slf4j</groupId>
                            <artifactId>slf4j-jdk14</artifactId>
                        </dependency>
                    </ignoredDependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
