<?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>

    <groupId>com.lancedb</groupId>
    <artifactId>lance-namespace-root</artifactId>
    <version>0.0.5</version>
    <packaging>pom</packaging>

    <name>${project.artifactId}</name>
    <description>Lance Namespace</description>
    <url>https://lancedb.github.io/lance-namespace</url>

    <licenses>
        <license>
            <name>Apache-2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:lancedb/lance-namespace.git</connection>
        <developerConnection>scm:git:git@github.com:lancedb/lance-namespace.git</developerConnection>
        <url>git@github.com:lancedb/lance-namespace.git</url>
        <tag>HEAD</tag>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/lancedb/lance-namespace/issues</url>
    </issueManagement>

    <developers>
        <developer>
            <name>LanceDB Developers</name>
            <email>developers@lancedb.com</email>
            <organization>LanceDB</organization>
            <organizationUrl>https://lancedb.com</organizationUrl>
        </developer>
    </developers>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <lance-namespace.version>0.0.5</lance-namespace.version>
        <arrow.version>15.0.0</arrow.version>
        <springboot.version>2.7.18</springboot.version>
        <junit-version>5.8.2</junit-version>

        <spotless.skip>false</spotless.skip>
        <spotless.version>2.30.0</spotless.version>
        <spotless.java.googlejavaformat.version>1.15.0</spotless.java.googlejavaformat.version>
        <!-- Please also update .scalafmt.conf when you change it here -->
        <spotless.scala.scalafmt.version>3.7.5</spotless.scala.scalafmt.version>
        <spotless.delimiter>package</spotless.delimiter>
        <spotless.license.header>
            /*
            * Licensed under the Apache License, Version 2.0 (the "License");
            * you may not use this file except in compliance with the License.
            * You may obtain a copy of the License at
            *
            *     http://www.apache.org/licenses/LICENSE-2.0
            *
            * Unless required by applicable law or agreed to in writing, software
            * distributed under the License is distributed on an "AS IS" BASIS,
            * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
            * See the License for the specific language governing permissions and
            * limitations under the License.
            */
        </spotless.license.header>

        <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
        <maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
    </properties>

    <modules>
        <module>lance-namespace-apache-client</module>
        <module>lance-namespace-springboot-server</module>
        <module>lance-namespace-core</module>
        <module>lance-namespace-adapter</module>
        <module>lance-namespace-hive</module>
        <module>lance-namespace-glue</module>
        <module>lance-namespace-lancedb</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.arrow</groupId>
                <artifactId>arrow-vector</artifactId>
                <version>${arrow.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.arrow</groupId>
                <artifactId>arrow-memory-netty</artifactId>
                <version>${arrow.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${springboot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>5.8.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.diffplug.spotless</groupId>
                    <artifactId>spotless-maven-plugin</artifactId>
                    <version>${spotless.version}</version>
                    <configuration>
                        <skip>${spotless.skip}</skip>
                        <upToDateChecking>
                            <enabled>true</enabled>
                        </upToDateChecking>
                        <java>
                            <includes>
                                <include>src/main/java/**/*.java</include>
                                <include>src/test/java/**/*.java</include>
                            </includes>
                            <googleJavaFormat>
                                <version>${spotless.java.googlejavaformat.version}</version>
                                <style>GOOGLE</style>
                            </googleJavaFormat>

                            <importOrder>
                                <order>com.lancedb.lance,,javax,java,\#</order>
                            </importOrder>

                            <removeUnusedImports />
                        </java>
                        <licenseHeader>
                            <content>${spotless.license.header}</content>
                            <delimiter>${spotless.delimiter}</delimiter>
                        </licenseHeader>
                    </configuration>
                    <executions>
                        <execution>
                            <id>spotless-check</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>apply</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven-checkstyle-plugin.version}</version>
                    <configuration>
                        <configLocation>checkstyle.xml</configLocation>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <violationSeverity>warning</violationSeverity>
                        <linkXRef>false</linkXRef>
                        <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
                        <suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
                    </configuration>
                    <executions>
                        <execution>
                            <id>validate</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>jdk11+</id>
            <activation>
                <jdk>[11,)</jdk>
            </activation>
            <properties>
                <!-- Ping release target to JDK8 to link only against Java 8 APIs -->
                <maven.compiler.release>8</maven.compiler.release>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.2.5</version>
                        <configuration>
                            <argLine>
                                -XX:+IgnoreUnrecognizedVMOptions
                                --add-opens=java.base/java.lang=ALL-UNNAMED
                                --add-opens=java.base/java.lang.invoke=ALL-UNNAMED
                                --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
                                --add-opens=java.base/java.io=ALL-UNNAMED
                                --add-opens=java.base/java.net=ALL-UNNAMED
                                --add-opens=java.base/java.nio=ALL-UNNAMED
                                --add-opens=java.base/java.util=ALL-UNNAMED
                                --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
                                --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
                                --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED
                                --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
                                --add-opens=java.base/sun.nio.cs=ALL-UNNAMED
                                --add-opens=java.base/sun.security.action=ALL-UNNAMED
                                --add-opens=java.base/sun.util.calendar=ALL-UNNAMED
                                --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED
                                -Djdk.reflect.useDirectMethodHandle=false
                                -Dio.netty.tryReflectionSetAccessible=true
                            </argLine>
                            <forkNode
                                    implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory" />
                            <useSystemClassLoader>false</useSystemClassLoader>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>deploy-to-ossrh</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.5.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>ossrh</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.6.0</version>
                        <configuration>
                            <doclint>none</doclint>
                            <quiet>true</quiet>
                            <nonavbar>true</nonavbar>
                            <notree>true</notree>
                            <nocomment>true</nocomment>
                            <nohelp>true</nohelp>
                            <detectJavaApiLink>false</detectJavaApiLink>
                            <links>
                                <link>https://javadoc.io/doc/com.lancedb/lance-namespace-apache-client</link>
                                <link>https://javadoc.io/doc/com.lancedb/lance-namespace-core</link>
                            </links>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
