<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) 2014 Google, Inc.

  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.
-->
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.google.cloud.bigdataoss</groupId>
    <artifactId>bigdataoss-parent</artifactId>
    <version>1.9.7</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <name>gcs-connector-hadoop2</name>
  <description>
    An implementation of org.apache.hadoop.fs.FileSystem targeting Google Cloud Storage
  </description>

  <artifactId>gcs-connector</artifactId>
  <version>hadoop2-1.9.7</version>

  <profiles>
    <profile>
      <id>hadoop1</id>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-core</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-test</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>**/GoogleHadoopFS.java</exclude>
              </excludes>
              <testExcludes>
                <!-- Exclude hadoop 2 specific tests -->
                <exclude>**/hcfs/*2Test.java</exclude>
                <exclude>**/contract/*.java</exclude>
              </testExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>hadoop2</id>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
          <classifier>tests</classifier>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-mapreduce-client-core</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <testExcludes>
                <exclude>**/hcfs/*1Test.java</exclude>
              </testExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>hadoop3</id>
      <dependencies>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-client-api</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-client-runtime</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-common</artifactId>
          <classifier>tests</classifier>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <testExcludes>
                <exclude>**/hcfs/*1Test.java</exclude>
              </testExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>integration-test</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>**/HadoopFileSystemIntegrationTest.java</exclude>
                <exclude>**/LocalFileSystemIntegrationTest.java</exclude>
                <exclude>**/WebHdfsIntegrationTest.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client-java6</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client-jackson2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-storage</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava-testlib</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.oauth-client</groupId>
      <artifactId>google-oauth-client</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.oauth-client</groupId>
      <artifactId>google-oauth-client-java6</artifactId>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud.bigdataoss</groupId>
      <artifactId>util</artifactId>
      <version>${bigdataoss.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.cloud.bigdataoss</groupId>
      <artifactId>util-hadoop</artifactId>
      <version>hadoop2-${bigdataoss.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.cloud.bigdataoss</groupId>
      <artifactId>gcsio</artifactId>
      <version>${bigdataoss.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.cloud.bigdataoss</groupId>
      <artifactId>gcsio</artifactId>
      <version>${bigdataoss.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>
    <dependency>
      <groupId>com.google.flogger</groupId>
      <artifactId>google-extensions</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.flogger</groupId>
      <artifactId>flogger-system-backend</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.flogger</groupId>
      <artifactId>flogger-log4j-backend</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/hadoop2/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
              </transformers>
              <filters>
                <filter>
                  <artifact>com.google.flogger:flogger-log4j-backend</artifact>
                  <includes>
                    <!--Avoid cleanup with minimizeJar that breaks Log4j logging-->
                    <include>**</include>
                  </includes>
                </filter>
              </filters>
              <artifactSet>
                <includes>
                  <include>com.fasterxml.jackson.core:jackson-core</include>
                  <include>com.google.api-client</include>
                  <include>com.google.apis</include>
                  <include>com.google.cloud.bigdataoss:util</include>
                  <include>com.google.cloud.bigdataoss:util-hadoop</include>
                  <include>com.google.cloud.bigdataoss:gcsio</include>
                  <include>com.google.flogger</include>
                  <include>com.google.guava</include>
                  <include>com.google.http-client:google-http-client</include>
                  <include>com.google.http-client:google-http-client-jackson2</include>
                  <include>com.google.oauth-client:google-oauth-client</include>
                  <include>com.google.oauth-client:google-oauth-client-java6</include>
                  <include>org.apache.httpcomponents:httpclient</include>
                  <include>org.apache.httpcomponents:httpcore</include>
                  <!-- needed by http client and versions conflict -->
                  <include>commons-codec:commons-codec</include>
                </includes>
              </artifactSet>
              <minimizeJar>true</minimizeJar>
              <relocations>
                <relocation>
                  <pattern>com</pattern>
                  <shadedPattern>com.google.cloud.hadoop.repackaged.gcs.com</shadedPattern>
                  <includes>
                    <include>com.fasterxml.**</include>
                    <include>com.google.api.**</include>
                    <include>com.google.cloud.hadoop.gcsio.**</include>
                    <include>com.google.cloud.hadoop.util.**</include>
                    <include>com.google.common.**</include>
                  </includes>
                  <excludes>
                    <exclude>com.google.cloud.hadoop.util.AccessTokenProvider</exclude>
                    <exclude>com.google.cloud.hadoop.util.AccessTokenProvider$AccessToken</exclude>
                  </excludes>
                </relocation>
                <relocation>
                  <pattern>org</pattern>
                  <shadedPattern>com.google.cloud.hadoop.repackaged.gcs.org</shadedPattern>
                  <includes>
                    <include>org.apache.commons.codec.**</include>
                    <include>org.apache.http.**</include>
                  </includes>
                </relocation>
              </relocations>
              <shadedArtifactAttached>true</shadedArtifactAttached>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
