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

       https://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
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>avro-parent</artifactId>
    <groupId>org.apache.avro</groupId>
    <version>1.11.3</version>
    <relativePath>../</relativePath>
  </parent>

  <artifactId>avro-mapred</artifactId>

  <name>Apache Avro Mapred API</name>
  <description>An org.apache.hadoop.mapred compatible API for using Avro Serialization in Hadoop</description>
  <packaging>bundle</packaging>

  <properties>
    <main.basedir>${project.parent.parent.basedir}</main.basedir>
    <osgi.import>
      !org.apache.avro.mapred*,
      org.apache.avro*;version="${project.version}",
      org.apache.hadoop*,
      *
    </osgi.import>
    <osgi.export>
      org.apache.avro.mapred*;version="${project.version}",
      org.apache.avro.hadoop*;version="${project.version}",
    </osgi.export>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>org.apache.avro.mapred</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <!-- Allow guava because hadoop brings it as a transitive dependency. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-banned-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <includes>
                    <exclude>com.google.guava:guava</exclude>
                  </includes>
                </bannedDependencies>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- some IPC tests hang if not run in a separate JVM -->
          <forkCount>1</forkCount>
          <reuseForks>false</reuseForks>
          <parallel>none</parallel>
        </configuration>
      </plugin>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>avro-maven-plugin</artifactId>
        <version>${project.version}</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>schema</goal>
            </goals>
          </execution>
          <execution>
            <id>test-schemas</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>schema</goal>
              <goal>protocol</goal>
            </goals>
            <!-- compile only test protocols and schemas and place them in the classpath. -->
            <configuration>
              <sourceDirectory></sourceDirectory>
              <testSourceDirectory>${parent.project.basedir}/../../../../share/test/schemas/</testSourceDirectory>
              <testOutputDirectory>${project.build.directory}/generated-test-sources/java</testOutputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>mapred-schema</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>protocol</goal>
            </goals>
            <configuration>
              <stringType>String</stringType>
              <includes>
                <include>**/mapred/tether/*.avpr</include>
              </includes>
              <sourceDirectory>${parent.project.basedir}/../../../../share/schemas/</sourceDirectory>
              <outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-test-source</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.basedir}/target/generated-test-sources/java</source>
                <source>${project.basedir}/target/generated-test-sources/avro</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.basedir}/target/generated-sources/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>avro-ipc</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>avro-ipc-jetty</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>avro-ipc</artifactId>
      <classifier>tests</classifier>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>avro</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <!-- hadoop's execution environment provides its own jars, usurping any others.
        So we should not include it here -->
      <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.xerial.snappy</groupId>
        <artifactId>snappy-java</artifactId>
        <scope>test</scope>
    </dependency>
  </dependencies>
</project>

