<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>uk.co.gresearch.spark</groupId>
  <artifactId>spark-extension_2.12</artifactId>
  <version>2.12.0-3.5</version>
  <name>Spark Extension</name>
  <description>A library that provides useful extensions to Apache Spark.</description>
  <inceptionYear>2020</inceptionYear>
  <url>https://github.com/G-Research</url>
  <licenses>
    <license>
      <name>Apache 2.0 License</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <scm>
    <connection>scm:git:git://github.com/g-research/spark-extension.git</connection>
    <developerConnection>scm:git:ssh://github.com:g-research/spark-extension.git</developerConnection>
    <url>https://github.com/g-research/spark-extension/tree/${project.scm.tag}</url>
    <tag>master</tag>
  </scm>
  <developers>
    <developer>
      <id>EnricoMi</id>
      <name>Enrico Minack</name>
      <email>github@enrico.minack.dev</email>
    </developer>
  </developers>
  <issueManagement>
    <system>GitHub Issues</system>
    <url>https://github.com/G-Research/spark-extension/issues</url>
  </issueManagement>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <encoding>UTF-8</encoding>
    <project.version>${project.version}</project.version>
    <scala.major.version>2</scala.major.version>
    <scala.minor.version>12</scala.minor.version>
    <scala.patch.version>18</scala.patch.version>
    <scala.compat.version>${scala.major.version}.${scala.minor.version}</scala.compat.version>
    <scala.version>${scala.compat.version}.${scala.patch.version}</scala.version>
    <!-- keep in-sync with python/requirements-3.3_2.13.txt -->
    <spark.major.version>3</spark.major.version>
    <spark.minor.version>5</spark.minor.version>
    <spark.patch.version>1</spark.patch.version>
    <spark.compat.version>${spark.major.version}.${spark.minor.version}</spark.compat.version>
    <spark.version>${spark.compat.version}.${spark.patch.version}</spark.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>

    <!-- pulls in spark-core, which is also a dependency, but referencing spark-core might break transitive dependencies -->
    <!-- see https://github.com/apache/spark/pull/40933#issuecomment-1536609310 -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-sql_${scala.compat.version}</artifactId>
      <version>${spark.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-hive_${scala.compat.version}</artifactId>
      <version>${spark.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.github.scopt</groupId>
      <artifactId>scopt_${scala.compat.version}</artifactId>
      <!-- keep DIFF.md section "Diff Spark application" synced with this value -->
      <version>4.1.0</version>
    </dependency>

    <!-- Test -->
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-catalyst_${scala.compat.version}</artifactId>
      <version>${spark.version}</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_${scala.compat.version}</artifactId>
      <version>3.3.0-SNAP4</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <repositories>
    <!-- the official source for Spark releases, mirrored to Maven central -->
    <repository>
      <id>apache releases</id>
      <name>Apache Releases</name>
      <url>https://repository.apache.org/content/repositories/releases/</url>
    </repository>
    <!-- required to resolve Spark snapshot versions -->
    <repository>
      <id>apache snapshots</id>
      <name>Apache Snapshots</name>
      <url>https://repository.apache.org/snapshots/</url>
    </repository>
  </repositories>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>

    <resources>
      <resource>
        <directory>python</directory>
        <includes>
          <include>gresearch/**/*.py</include>
          <include>requirements.txt</include>
        </includes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.5.0</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/scala-spark-${spark.compat.version}</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>write-project-properties</goal>
            </goals>
            <configuration>
              <outputFile>${project.build.outputDirectory}/spark-extension-build.properties</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.coderplus.maven.plugins</groupId>
        <artifactId>copy-rename-maven-plugin</artifactId>
        <version>1.0.1</version>
        <executions>
          <execution>
            <id>provide-requirements-txt</id>
            <phase>compile</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <sourceFile>${project.basedir}/python/requirements-${spark.compat.version}_${scala.compat.version}.txt</sourceFile>
              <destinationFile>${project.basedir}/python/requirements.txt</destinationFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <version>2.15.2</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <args>
                <arg>-dependencyfile</arg>
                <arg>${project.build.directory}/.scala_dependencies</arg>
              </args>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>uk.co.gresearch.spark.diff.App</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <!-- scalafmt -->
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.30.0</version>
        <configuration>
          <scala>
            <scalafmt>
              <version>3.7.17</version>
              <file>${project.basedir}/.scalafmt.conf</file>
            </scalafmt>
          </scala>
        </configuration>
        <executions>
          <execution>
            <!-- Runs in compile phase to fail fast in case of formatting issues.-->
            <id>spotless-check</id>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- run java tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.1.2</version>
        <configuration>
          <skipTests>false</skipTests>
        </configuration>
      </plugin>
      <!-- run scalatest -->
      <plugin>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest-maven-plugin</artifactId>
        <version>2.2.0</version>
        <configuration>
          <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
          <junitxml>.</junitxml>
          <filereports>WDF TestSuite.txt</filereports>
        </configuration>
        <executions>
          <execution>
            <id>test</id>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>1.6.13</version>
        <extensions>true</extensions>
        <configuration>
          <serverId>ossrh</serverId>
          <nexusUrl>https://oss.sonatype.org/</nexusUrl>
          <autoReleaseAfterClose>false</autoReleaseAfterClose>
          <stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>4.8.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>doc-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>3.1.2</version>
      </plugin>
    </plugins>
  </reporting>

</project>
