<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>
    <groupId>com.snowflake</groupId>
    <artifactId>snowpark</artifactId>
    <version>1.1.0</version>
    <name>${project.artifactId}</name>
    <description>Snowflake's DataFrame API</description>
    <url>https://www.snowflake.com/</url>
    <inceptionYear>2018</inceptionYear>
    <licenses>
        <license>
            <name>Snowflake License</name>
            <url>https://www.snowflake.com/legal/</url>
        </license>
    </licenses>

    <developers>
      <developer>
        <name>Snowflake Support Team</name>
        <email>snowflake-java@snowflake.net</email>
        <organization>Snowflake Computing</organization>
        <organizationUrl>https://www.snowflake.com</organizationUrl>
      </developer>
    </developers>

    <scm>
      <connection>scm:git:git://github.com/snowflakedb/snowpark</connection>
      <url>http://github.com/snowflakedb/snowpark/tree/master</url>
    </scm>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <encoding>UTF-8</encoding>
        <scala.version>2.12.11</scala.version>
        <scala.compat.version>2.12</scala.compat.version>
        <spec2.version>4.2.0</spec2.version>
        <snowflake.jdbc.version>3.13.10</snowflake.jdbc.version>
        <version.scala.binary>${scala.compat.version}</version.scala.binary>
        <doctitle>Snowpark ${project.version}</doctitle>
        <scoverage.plugin.version>1.4.0</scoverage.plugin.version>
        <bouncycastle.version>1.64</bouncycastle.version>
        <scoverage.aggregate>true</scoverage.aggregate>
        <scalaPluginVersion>4.3.0</scalaPluginVersion>
    </properties>

    <repositories>
        <repository>
            <id>osgeo</id>
            <name>OSGeo Release Repository</name>
            <url>https://repo.osgeo.org/repository/release/</url>
            <snapshots><enabled>false</enabled></snapshots>
            <releases><enabled>true</enabled></releases>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-compiler</artifactId>
            <version>${scala.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.32</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.32</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.15</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/net.snowflake/snowflake-jdbc -->
        <dependency>
            <groupId>net.snowflake</groupId>
            <artifactId>snowflake-jdbc</artifactId>
            <version>${snowflake.jdbc.version}</version>
        </dependency>
        <!-- SQL formatter-->
        <dependency>
            <groupId>com.github.vertical-blank</groupId>
            <artifactId>sql-formatter</artifactId>
            <version>1.0.2</version>
        </dependency>


        <!-- Dependency for Variant UDF -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.10.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.10.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.23.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.compat.version}</artifactId>
            <version>3.0.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.specs2</groupId>
            <artifactId>specs2-core_${scala.compat.version}</artifactId>
            <version>${spec2.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.specs2</groupId>
            <artifactId>specs2-junit_${scala.compat.version}</artifactId>
            <version>${spec2.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.antipathy</groupId>
                <artifactId>mvn-scalafmt_${version.scala.binary}</artifactId>
                <version>1.0.2</version>
                <configuration>
                    <configLocation>${project.basedir}/.scalafmt.conf</configLocation>
                    <skipTestSources>false</skipTestSources>
                    <skipSources>false</skipSources>
                    <respectVersion>false</respectVersion>
                    <sourceDirectories>
                        <param>${project.basedir}/src/main/scala</param>
                    </sourceDirectories>
                    <testSourceDirectories>
                        <param>${project.basedir}/src/test/scala</param>
                    </testSourceDirectories>
                    <validateOnly>false</validateOnly>
                </configuration>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Google Java Format -->
            <plugin>
                <groupId>com.coveo</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>2.9.1</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.scalastyle</groupId>
                <artifactId>scalastyle-maven-plugin</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <verbose>false</verbose>
                    <failOnViolation>true</failOnViolation>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    <failOnWarning>false</failOnWarning>
                    <sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
                    <testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
                    <configLocation>${project.basedir}/scalastyle_config.xml</configLocation>
                    <outputFile>${project.basedir}/scalastyle-output.xml</outputFile>
                    <outputEncoding>UTF-8</outputEncoding>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- see http://davidb.github.com/scala-maven-plugin -->
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>${scalaPluginVersion}</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-dependencyfile</arg>
                                <arg>${project.build.directory}/.scala_dependencies</arg>
                            </args>
                        </configuration>
                    </execution>
                    <execution>
                        <id>scala-test-compile-first</id>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-doc</id>
                        <goals>
                            <goal>doc</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <args>
                                <arg>-groups</arg>
                                <arg>-doc-footer</arg>
                                <arg>© 2021 Snowflake Inc. All Rights Reserved</arg>
                                <arg>-skip-packages</arg>
                                <arg>org:com.snowflake.snowpark.internal:com.snowflake.snowpark_java</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <sourceDir>src/main/scala</sourceDir>
                </configuration>
            </plugin>
            <!-- disable default Maven Compiler plugin, use scala one instead-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <skipMain>true</skipMain> <!-- skip compile -->
                    <skip>true</skip> <!-- skip testCompile -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
                <configuration>
                    <skip>true</skip>
                    <includes>
                        <include>**/*Suite.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>2.0.0</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports
                    </reportsDirectory>
                    <junitxml>.</junitxml>
                    <filereports>TestSuiteReport.txt</filereports>
                    <tagsToInclude>${tagsToInclude}</tagsToInclude>
                    <tagsToExclude>${tagsToExclude}</tagsToExclude>
                    <!-- Comma separated list of JUnit test class names to execute -->
                    <!-- <jUnitClasses>samples.AppTest</jUnitClasses> -->
                </configuration>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-dependencies-test</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>test</includeScope>
                            <outputDirectory>${project.build.directory}/test-lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <!-- We are building three packages with the following executions:
                         1. snowpark-version.jar                     - snowpark + udf dependency jars
                         2. snowpark-version-with-dependencies.jar   - snowpark + all dependency jars needed for XP
                         3. fat-test-snowpark-version-fat-test.jar   - snowpark + all dependency jars and tests jars
                         If we set appendAssemblyId = false, the generated jar will replace the main jar in the artifact.
                         Therefore if we have more than one appendAssemblyId = false, the main jar in the artifact
                         will be replaced multiple times, resulting some jars not tracked by Maven anymore.
                         Details here: https://stackoverflow.com/questions/38482839/maven-assembly-plugin-how-to-use-appendassemblyid
                    -->
                    <!-- NOTE!!! Please also modify profile ossrh-deploy after changing anything here -->
                    <execution>
                        <id>with-udf-dependency</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>${project.artifactId}-${project.version}</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>src/assembly/with-udf-dependency.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>with-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/with-dependencies.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>fat-test</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>fat-test-${project.artifactId}-${project.version}</finalName>
                            <descriptors>
                                <descriptor>src/assembly/fat-test.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-tar-zip</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/bin.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.7</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/DataTypes.class</include>
                                <include>**/snowpark_java/**</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.scoverage</groupId>
                <artifactId>scoverage-maven-plugin</artifactId>
                <version>${scoverage.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal> <!-- or integration-check -->
                        </goals>
                        <phase>prepare-package</phase> <!-- or any other phase -->
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-gpg-plugin</artifactId>
              <version>1.6</version>
                <executions>
                  <execution>
                    <id>sign-deploy-artifacts</id>
                    <phase>package</phase>
                    <goals>
                      <goal>sign</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.nicoulaj.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <version>1.10</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>artifacts</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <algorithms>
                        <algorithm>SHA-256</algorithm>
                        <algorithm>md5</algorithm>
                    </algorithms>
                </configuration>
            </plugin>

        </plugins>

        <!-- disable default maven deploy plugin since we are using gpg:sign-and-deploy-file -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
          <id>ossrh-deploy</id>
          <activation>
              <property>
                  <name>ossrh-deploy</name>
              </property>
          </activation>
          <build>
              <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.3.0</version>
                    <executions>
                        <execution>
                            <id>generate-tar-zip</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>with-dependencies</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>fat-test</id>
                            <phase>none</phase>
                        </execution>
                    </executions>
                 </plugin>
                  <plugin>
                      <artifactId>maven-jar-plugin</artifactId>
                      <version>3.1.0</version>
                      <executions>
                          <execution>
                              <id>empty-javadoc-jar</id>
                              <phase>package</phase>
                              <goals>
                                  <goal>jar</goal>
                              </goals>
                              <configuration>
                                  <classifier>javadoc</classifier>
                                  <classesDirectory>${basedir}/javadoc</classesDirectory>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-gpg-plugin</artifactId>
                      <version>1.6</version>
                      <executions>
                          <execution>
                            <id>sign-deploy-artifacts</id>
                            <phase>none</phase>
                          </execution>
                          <execution>
                              <id>sign-and-deploy-file</id>
                              <phase>deploy</phase>
                              <goals>
                                  <goal>sign-and-deploy-file</goal>
                              </goals>
                              <configuration>
                                  <file>target/${project.artifactId}-${project.version}.jar</file>
                                  <repositoryId>ossrh</repositoryId>
                                  <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
                                  <pomFile>pom.xml</pomFile>
                                  <javadoc>target/${project.artifactId}-${project.version}-javadoc.jar</javadoc>
                                  <keyname>${env.GPG_KEY_ID}</keyname>
                                  <passphrase>${env.GPG_KEY_PASSPHRASE}</passphrase>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
              </plugins>
          </build>
      </profile>
    </profiles>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.scoverage</groupId>
                <artifactId>scoverage-maven-plugin</artifactId>
                <version>${scoverage.plugin.version}</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report-only</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
</project>
