<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Copyright 2018 ABSA Group Limited
  ~
  ~ 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>

    <groupId>za.co.absa</groupId>
    <artifactId>atum-parent_2.12</artifactId>
    <version>3.7.0</version>

    <packaging>pom</packaging>

    <modules>
        <module>atum</module>
        <module>model</module>
        <module>examples</module>
        <module>atum-s3-sdk-extension</module>
        <module>examples-s3-sdk-extension</module>
    </modules>

    <name>Atum</name>
    <description>Dynamic data completeness and accuracy at enterprise scale in Apache Spark</description>
    <url>https://github.com/AbsaOSS/atum</url>
    <inceptionYear>2018</inceptionYear>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <organization>
        <name>ABSA Group Limited</name>
        <url>https://www.absa.africa</url>
    </organization>

    <developers>
        <developer>
            <id>yruslan</id>
            <name>Ruslan Iushchenko</name>
            <timezone>Europe/Prague</timezone>
            <url>https://github.com/yruslan</url>
        </developer>
        <developer>
            <id>dk1844</id>
            <name>Daniel Kavan</name>
            <timezone>Europe/Prague</timezone>
            <url>https://github.com/dk1844</url>
        </developer>
    </developers>

    <scm>
        <connection>${scm.connection}</connection>
        <developerConnection>${scm.developerConnection}</developerConnection>
        <url>${scm.url}</url>
        <tag>v3.7.0</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <java.version>1.8</java.version>
        <!-- Common project properties -->
        <encoding>UTF-8</encoding>
        <timestamp>${maven.build.timestamp}</timestamp>
        <span.scale.factor>1</span.scale.factor>

        <!-- Build and plugins properties -->
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssX</maven.build.timestamp.format>
        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
        <maven.scala.version>3.2.0</maven.scala.version>
        <maven.shade.version>2.3</maven.shade.version>
        <maven.sources.version>3.0.1</maven.sources.version>
        <maven.surefire.version>2.18.1</maven.surefire.version>

        <!-- This is server id for configuring access credentials via settings.xml-->
        <project.scm.id>atum-scm-server</project.scm.id>

        <!-- Overridable SCM properties to support multiple SCM URLs-->
        <scm.connection>scm:git:git://github.com/AbsaOSS/atum.git</scm.connection>
        <scm.developerConnection>scm:git:ssh://git@github.com/AbsaOSS/atum.git</scm.developerConnection>
        <scm.url>http://github.com/AbsaOSS/atum/tree/master</scm.url>

        <!-- Cross Compilation Properties -->
        <default.scala.binary.version>2.11</default.scala.binary.version>
        <default.scala.version>${scala_2.11.version}</default.scala.version>

        <scala_2.11.version>2.11.12</scala_2.11.version>
        <scala_2.12.version>2.12.12</scala_2.12.version>

        <!-- Controlled by `scala-cross-build` plugin -->
        <scala.version>2.12.12</scala.version>
        <scala.binary.version>2.12</scala.binary.version>

        <!-- Frameworks and libraries -->
        <json4s.version>3.5.3</json4s.version> <!-- This version is set to be compatible with Spark 2.4.5 -->
        <scalatest.maven.version>2.0.2</scalatest.maven.version>
        <scalatest.version>3.2.2</scalatest.version>
        <slf4j.version>1.7.25</slf4j.version>
        <specs.version>2.5</specs.version>
        <aws.java.sdk.version>2.13.65</aws.java.sdk.version>
        <mockito.scala.version>1.15.0</mockito.scala.version>
        <commons.version>0.0.27</commons.version>
        <typesafe.config.version>1.4.1</typesafe.config.version>
        <hadoop.version>2.8.5</hadoop.version>

        <!-- Spark versions -->
        <spark-24.version>2.4.6</spark-24.version>
        <spark-31.version>3.1.2</spark-31.version>

        <spark.version>${spark-24.version}</spark.version>

        <!-- Scalastyle-->
        <quiet.scalastyle.check>true</quiet.scalastyle.check>
        <scalastyle.configLocation>${project.basedir}/scalastyle-config.xml</scalastyle.configLocation>
    </properties>

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

        <!-- spark -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_${scala.binary.version}</artifactId>
            <version>${spark.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_${scala.binary.version}</artifactId>
            <version>${spark.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- libraries -->
        <dependency>
            <groupId>org.json4s</groupId>
            <artifactId>json4s-ext_${scala.binary.version}</artifactId>
            <version>${json4s.version}</version>
        </dependency>

        <!-- scalatest -->
        <dependency>
            <groupId>org.specs2</groupId>
            <artifactId>specs2-core_${scala.binary.version}</artifactId>
            <version>${specs.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
            <version>${scalatest.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.scalastyle</groupId>
                    <artifactId>scalastyle-maven-plugin</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <quiet>${quiet.scalastyle.check}</quiet>
                        <verbose>false</verbose>
                        <failOnViolation>true</failOnViolation>
                        <failOnWarning>false</failOnWarning>
                        <includeTestSourceDirectory>false</includeTestSourceDirectory>
                        <sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
                        <testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
                        <configLocation>${scalastyle.configLocation}</configLocation>
                        <outputFile>${project.basedir}/target/scalastyle-output.xml</outputFile>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- the Maven Scala plugin -->
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>${maven.scala.version}</version>
                <configuration>
                    <checkMultipleScalaVersions>false</checkMultipleScalaVersions>
                    <recompileMode>incremental</recompileMode>
                    <args>
                        <arg>-target:jvm-${java.version}</arg>
                    </args>
                    <javacArgs>
                        <javacArg>-source</javacArg><javacArg>${java.version}</javacArg>
                        <javacArg>-target</javacArg><javacArg>${java.version}</javacArg>
                    </javacArgs>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>doc-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- disable surefire -->
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <!-- enable scalatest -->
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>${scalatest.maven.version}</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                    <junitxml>.</junitxml>
                    <filereports>WDF TestSuite.txt</filereports>
                    <spanScaleFactor>${span.scale.factor}</spanScaleFactor>
                </configuration>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven.sources.version}</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-release-plugin</artifactId>
                <version>2.4.2</version>
                <configuration>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules> <!-- all modules to have the same version -->
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-gitexe</artifactId>
                        <version>1.8.1</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>com.github.wajda</groupId>
                <artifactId>scala-cross-build-maven-plugin</artifactId>
                <version>0.2.1</version>
                <configuration>
                    <defaultScalaBinaryVersion>${default.scala.binary.version}</defaultScalaBinaryVersion>
                    <defaultScalaVersion>${default.scala.version}</defaultScalaVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Cross-building profiles -->
        <profile>
            <id>scala-2.11</id>
            <properties>
                <scala.binary.version>2.11</scala.binary.version>
                <scala.version>${scala_2.11.version}</scala.version>
            </properties>
        </profile>
        <profile>
            <id>scala-2.12</id>
            <properties>
                <scala.binary.version>2.12</scala.binary.version>
                <scala.version>${scala_2.12.version}</scala.version>
            </properties>
        </profile>

        <!-- Spark profiles -->
        <profile>
            <id>spark-2.4</id>
            <properties>
                <spark.version>${spark-24.version}</spark.version>
                <json4s.version>3.5.3</json4s.version>
            </properties>
        </profile>
        <profile>
            <id>spark-3.1</id>
            <properties>
                <spark.version>${spark-31.version}</spark.version>
                <json4s.version>3.7.0-M5</json4s.version>
            </properties>
        </profile>

        <profile>
            <id>license-check</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.rat</groupId>
                        <artifactId>apache-rat-plugin</artifactId>
                        <version>0.12</version>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <licenses>
                                <license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense">
                                    <licenseFamilyCategory>AL20</licenseFamilyCategory>
                                    <licenseFamilyName>Apache License, 2.0</licenseFamilyName>
                                    <notes />
                                    <patterns>
                                        <pattern>Copyright [0-9]{4} ABSA Group Limited</pattern>
                                    </patterns>
                                </license>
                            </licenses>
                            <excludes>
                                <exclude>**/*.json</exclude>
                                <exclude>**/*.csv</exclude>
                                <exclude>**/*.txt</exclude>
                                <exclude>**/*.info</exclude>
                                <exclude>**/*.md</exclude>
                                <exclude>**/_INFO</exclude>
                                <exclude>**/_SUCCESS</exclude>
                                <exclude>**/org.apache.spark.sql.sources.DataSourceRegister</exclude>
                                <exclude>dependency-reduced-pom.xml</exclude>
                                <exclude>**/org.mockito.plugins.MockMaker</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>scalastyle</id>
            <properties>
                <quiet.scalastyle.check>false</quiet.scalastyle.check>
            </properties>
        </profile>

        <profile>
            <id>public</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
