<?xml version="1.0" encoding="UTF-8"?>
<!--
Can build a JAR and an assembled JAR.  The first is useful for programming a larger
component, and will most likely require assembly and shading to use.  The second is
useful for inserting directly into Spark.

To publish to Maven Central:
    mvn deploy
    mvn -Passembly deploy

To export to S3:
    mvn package s3-storage-wagon:s3-upload@upload-jar
    mvn -Passembly package s3-storage-wagon:s3-upload@upload-jar
-->
<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>io.lakefs</groupId>
    <artifactId>hadoop-lakefs${name-suffix}</artifactId>
    <packaging>jar</packaging>
    <name>hadoop-lakefs${name-suffix}</name>
    <version>0.2.3</version>
    <url>https://lakefs.io</url>
    <scm>
        <connection>scm:git:git@github.com:treeverse/lakeFS.git</connection>
        <developerConnection>scm:git:git@github.com:treeverse/lakeFS.git</developerConnection>
        <url>https://github.com/treeverse/lakeFS</url>
    </scm>
    <parent>
        <groupId>io.lakefs</groupId>
        <artifactId>lakefs-parent</artifactId>
        <version>0</version>
    </parent>

    <licenses>
        <license>
            <name>apache2</name>
            <url>http://www.apache.org/licenses/</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Treeverse lakeFS dev</name>
            <email>services@treeverse.io</email>
            <organization>lakefs.io</organization>
            <organizationUrl>https://lakefs.io</organizationUrl>
        </developer>
    </developers>

    <profiles>
        <profile>
            <id>contract-tests-hadoop2</id>
            <properties>
                <exclude.tests>io/lakefs/contract/hadoop3/**</exclude.tests>
                <contract_tests.resource_dir>../../test/lakefsfs_contract/</contract_tests.resource_dir>
                <hadoop.version>2.7.7</hadoop.version>
            </properties>
            <build>
                <resources>
                    <resource>
                        <directory>${contract_tests.resource_dir}</directory>
                    </resource>
                </resources>
            </build>
        </profile>
        <profile>
            <id>contract-tests-hadoop3</id>
            <properties>
                <exclude.tests>io/lakefs/contract/hadoop2/**</exclude.tests>
                <contract_tests.resource_dir>../../test/lakefsfs_contract/</contract_tests.resource_dir>
                <hadoop.version>3.1.4</hadoop.version>
            </properties>
            <build>
                <resources>
                    <resource>
                        <directory>${contract_tests.resource_dir}</directory>
                    </resource>
                </resources>
            </build>
        </profile>
        <profile>
            <id>contract-tests-hadoop3-presigned</id>
            <properties>
                <exclude.tests>io/lakefs/contract/hadoop2/**</exclude.tests>
                <contract_tests.resource_dir>../../test/lakefsfs_contract/</contract_tests.resource_dir>
                <hadoop.version>3.1.4</hadoop.version>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.1.2</version>
                        <configuration>
                            <systemPropertyVariables>
                                <lakefs.access_mode>presigned</lakefs.access_mode>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
                <resources>
                    <resource>
                        <directory>${contract_tests.resource_dir}</directory>
                    </resource>
                </resources>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.2.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <source>1.8</source>
                                    <doclint>none</doclint>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>assembly</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>3.4.1</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <filters>
                                        <filter>
                                            <artifact>*:*</artifact>
                                            <excludes>
                                                <exclude>module-info.class</exclude>
                                                <exclude>META-INF/maven/**</exclude>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                            </excludes>
                                        </filter>
                                    </filters>
                                    <relocations>
                                        <relocation>
                                            <pattern>org.apache.httpcomponents</pattern>
                                            <shadedPattern>io.lakefs.hadoopfs.shade.org.apache.httpcomponents</shadedPattern>
                                        </relocation>
                                        <relocation>
                                            <pattern>okio</pattern>
                                            <shadedPattern>io.lakefs.hadoopfs.shade.okio</shadedPattern>
                                        </relocation>
                                        <relocation>
                                            <pattern>okhttp3</pattern>
                                            <shadedPattern>io.lakefs.hadoop.shade.okhttp3</shadedPattern>
                                        </relocation>
                                        <relocation>
                                            <pattern>com.google.gson</pattern>
                                            <shadedPattern>io.lakefs.hadoop.shade.gson</shadedPattern>
                                        </relocation>
                                        <relocation>
                                            <pattern>io.gsonfire</pattern>
                                            <shadedPattern>io.lakefs.hadoop.shade.gsonfire</shadedPattern>
                                        </relocation>
                                        <relocation>
                                            <pattern>io.lakefs.clients.sdk</pattern>
                                            <shadedPattern>io.lakefs.hadoop.shade.sdk</shadedPattern>
                                        </relocation>
                                    </relocations>
                                    <transformers>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <manifestEntries>
                                                <Implementation-Version>${project.version}</Implementation-Version>
                                            </manifestEntries>
                                        </transformer>
                                    </transformers>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <name-suffix>-assembly</name-suffix>
            </properties>
        </profile>
    </profiles>

    <properties>
        <exclude.tests>io/lakefs/contract/**</exclude.tests>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <name-suffix/>          <!-- Set via profile to rename JAR -->
        <hadoop.version>2.7.7</hadoop.version>
        <finalName>${project.artifactId}-${project.version}</finalName>
    </properties>
    <build>
        <finalName>${finalName}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.2</version>
                <configuration>
                    <excludes>
                        <exclude>${exclude.tests}</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <testExcludes>
                        <testExclude>${exclude.tests}</testExclude>
                    </testExcludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.gkatzioura.maven.cloud</groupId>
                <artifactId>s3-storage-wagon</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <id>upload-jar</id>
                        <goals>
                            <goal>s3-upload</goal>
                        </goals>
                        <configuration>
                            <path>target/${project.artifactId}-${project.version}.jar</path>
                            <bucket>treeverse-clients-us-east</bucket>
                            <region>us-east-1</region>
                            <key>hadoop/${project.artifactId}-${project.version}.jar</key>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>io.lakefs</groupId>
            <artifactId>sdk</artifactId>
            <version>1.12.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>${hadoop.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <scope>test</scope>
            <type>test-jar</type>
            <version>${hadoop.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-aws</artifactId>
            <version>${hadoop.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>        <!-- needed for aws-java-sdk in tests(!) -->
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.aventrix.jnanoid</groupId>
            <artifactId>jnanoid</artifactId>
            <version>2.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.testcontainers</groupId>
          <artifactId>testcontainers</artifactId>
          <version>1.16.3</version>
          <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver -->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver</artifactId>
            <version>4.10.0</version>
            <scope>test</scope>
        </dependency>

	    <!--
	     https://stackoverflow.com/questions/35569092/java-lang-classnotfoundexception-com-fasterxml-jackson-annotation-jsonincludev
	     says to keep all of these on the same versions -->
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.13.4.2</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-core</artifactId>
          <version>2.12.3</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
          <version>2.12.3</version>
          <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-junit-rule-no-dependencies</artifactId>
            <version>5.14.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-core</artifactId>
            <version>5.15.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.immutables</groupId>
            <artifactId>value</artifactId>
            <version>2.9.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>32.1.2-jre</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
