<?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
  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.8.1</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 Serializatin in Hadoop</description>
  <packaging>bundle</packaging>

  <properties>
    <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>${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.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>main</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
          </execution>
          <execution>
            <id>with-classifier</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
              <classifier>${envClassifier}</classifier>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>enforce-banned-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <!-- Ban all versions of Guava other than 11.0.2 that Hadoop uses -->
                  <excludes>
                    <exclude>com.google.guava:guava</exclude>
                  </excludes>
                  <includes>
                    <include>com.google.guava:guava:11.0.2</include>
                  </includes>
                </bannedDependencies>
              </rules>
              <fail>true</fail>
            </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</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.easymock</groupId>
      <artifactId>easymock</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>${hamcrest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
    </dependency>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>${commons-codec.version}</version>
    </dependency>
  </dependencies>

  <profiles>
     <profile>
      <id>hadoop1</id>
      <activation>
        <property>
          <name>hadoop.version</name>
          <value>1</value>
        </property>
      </activation>
      <properties>
        <envClassifier>hadoop1</envClassifier>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-core</artifactId>
          <!-- hadoop's execution environment provides its own jars, usurping any others.
            So we should not include it here -->
          <scope>provided</scope>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>hadoop2</id>
      <activation>
        <property>
          <name>!hadoop.version</name> <!-- if no hadoop.version is set -->
        </property>
      </activation>
      <properties>
        <envClassifier>hadoop2</envClassifier>
      </properties>
      <dependencies>
        <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>
      </dependencies>
    </profile>
  </profiles>

</project>

