<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you 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.
-->
<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.apache.arrow</groupId>
    <artifactId>arrow-java-root</artifactId>
    <version>19.0.0</version>
  </parent>
  <artifactId>arrow-vector</artifactId>
  <name>Arrow Vectors</name>
  <description>An off-heap reference implementation for Arrow columnar data format.</description>

  <dependencies>
    <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.immutables</groupId>
      <artifactId>value-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.21.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-memory-netty</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.arrow</groupId>
      <artifactId>arrow-memory-unsafe</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.flatbuffers</groupId>
      <artifactId>flatbuffers-java</artifactId>
      <version>${dep.fbs.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <configuration>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.apache.arrow:arrow-memory-unsafe</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>run-unsafe</id>
            <goals>
              <goal>test</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.apache.arrow:arrow-memory-netty</classpathDependencyExclude>
              </classpathDependencyExcludes>
              <reportNameSuffix>netty</reportNameSuffix>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration combine.children="append">
          <compilerArgs>
            <arg>-Werror</arg>
          </compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <!-- generate sources from fmpp -->
        <groupId>org.apache.drill.tools</groupId>
        <artifactId>drill-fmpp-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-fmpp</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <config>src/main/codegen/config.fmpp</config>
              <output>${project.build.directory}/generated-sources/fmpp</output>
              <templates>src/main/codegen/templates</templates>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>shade</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <artifactSet>
                <includes>
                  <include>org.apache.arrow:arrow-format</include>
                  <include>com.google.flatbuffers:*</include>
                </includes>
              </artifactSet>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>shade-format-flatbuffers</shadedClassifierName>
              <relocations>
                <relocation>
                  <pattern>com.google.flatbuffers</pattern>
                  <shadedPattern>arrow.vector.com.google.flatbuffers</shadedPattern>
                </relocation>
              </relocations>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/LICENSE</exclude>
                    <exclude>META-INF/NOTICE</exclude>
                  </excludes>
                </filter>
              </filters>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                  <resource>META-INF/LICENSE.txt</resource>
                  <file>src/shade/LICENSE.txt</file>
                </transformer>
                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                  <resource>META-INF/NOTICE.txt</resource>
                  <file>src/shade/NOTICE.txt</file>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>codegen-jar</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <!-- Arrow's type system has many types, and projects building operations across Arrow data
              (comparisons, casts, aggregations) benefit from generating type-specialized code rather
              than hand-writing implementations for each type.
              The TDD files provide a machine-readable definition of Arrow's types that enables this.
              Including them in the distribution allows downstream projects to generate code that
              stays in sync as Arrow's type system evolves.-->
              <classifier>codegen</classifier>
              <classesDirectory>${basedir}/src/main/codegen</classesDirectory>
              <includes>
                <include>**/*.tdd</include>
                <include>**/*.fmpp</include>
                <include>**/*.ftl</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!-- This profile turns on integration testing. It activates the failsafe plugin and will run any tests
      with the 'IT' prefix. This should be run in a separate CI build or on developers machines as it potentially
      uses quite a bit of memory. Activate the tests by adding -Pintegration-tests to your maven command line -->
      <id>integration-tests</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds>
              <systemPropertyVariables>
                <arrow.memory.debug.allocator>false</arrow.memory.debug.allocator>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>default-it</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
