<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.stoys</groupId>
    <artifactId>stoys-parent</artifactId>
    <version>0.4.0</version>
    <packaging>pom</packaging>

    <name>stoys</name>
    <description>SToys - mostly Scala and Spark tools.</description>
    <url>https://github.com/stoys-io/stoys</url>
    <inceptionYear>2019</inceptionYear>

    <scm>
        <url>https://github.com/stoys-io/stoys.git</url>
        <connection>scm:git:git@github.com:stoys-io/stoys.git</connection>
        <developerConnection>scm:git:git@github.com:stoys-io/stoys.git</developerConnection>
        <tag>stoys-0.4.0</tag>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/stoys-io/stoys/issues/</url>
    </issueManagement>

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

    <developers>
        <developer>
            <name>Jan Prach</name>
            <email>jendap@gmail.com</email>
            <organization>stoys</organization>
            <organizationUrl>https://stoys.io</organizationUrl>
        </developer>
    </developers>

    <modules>
        <module>bom</module>
        <module>scala</module>
        <module>spark</module>
        <module>spark-db</module>
        <module>spark-du</module>
        <module>spark-excel</module>
        <module>spark-test</module>
    </modules>

    <properties>
        <main.class>UNSPECIFIED</main.class>

        <jdk.version>11</jdk.version>
        <character.encoding>UTF-8</character.encoding>

        <scala.version>2.12.14</scala.version>
        <scala.compat.version>2.12</scala.compat.version>

        <commons-codec.version>1.15</commons-codec.version>
        <commons-io.version>2.11.0</commons-io.version>
        <commons-text.version>1.9</commons-text.version>
        <delta.version>1.0.0</delta.version>
        <jackson.version>2.12.5</jackson.version>
        <log4s.version>1.10.0</log4s.version>
        <persistence-api.version>2.2</persistence-api.version>
        <scala-collection-compat.version>2.5.0</scala-collection-compat.version>
        <scalatest.version>3.2.9</scalatest.version>
        <spark.version>3.1.2</spark.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- scala -->
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-library</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>org.scala-lang</groupId>
                <artifactId>scala-reflect</artifactId>
                <version>${scala.version}</version>
            </dependency>
            <dependency>
                <groupId>org.scala-lang.modules</groupId>
                <artifactId>scala-collection-compat_${scala.compat.version}</artifactId>
                <version>${scala-collection-compat.version}</version>
            </dependency>

            <!-- jdbc -->
            <dependency>
                <groupId>javax.persistence</groupId>
                <artifactId>javax.persistence-api</artifactId>
                <version>${persistence-api.version}</version>
            </dependency>

            <!-- commons -->
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>${commons-codec.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-text</artifactId>
                <version>${commons-text.version}</version>
            </dependency>

            <!-- jackson -->
            <dependency>
                <groupId>com.fasterxml.jackson</groupId>
                <artifactId>jackson-bom</artifactId>
                <version>${jackson.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson.version}</version>
            </dependency>

            <!-- spark -->
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-core_${scala.compat.version}</artifactId>
                <version>${spark.version}</version>
                <scope>provided</scope>
            </dependency>
            <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-mllib_${scala.compat.version}</artifactId>
                <version>${spark.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-avro_${scala.compat.version}</artifactId>
                <version>${spark.version}</version>
                <scope>provided</scope>
            </dependency>

            <!-- spark libraries -->
            <dependency>
                <groupId>io.delta</groupId>
                <artifactId>delta-core_${scala.compat.version}</artifactId>
                <version>${delta.version}</version>
                <scope>provided</scope>
            </dependency>

            <!-- scala libs -->
            <dependency>
                <groupId>org.log4s</groupId>
                <artifactId>log4s_${scala.compat.version}</artifactId>
                <version>${log4s.version}</version>
            </dependency>

            <!-- test -->
            <dependency>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest_${scala.compat.version}</artifactId>
                <version>${scalatest.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <!-- maven -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <encoding>${character.encoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <compilerVersion>${jdk.version}</compilerVersion>
                        <source>${jdk.version}</source>
                        <target>${jdk.version}</target>
                        <encoding>${character.encoding}</encoding>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <failIfNoTests>false</failIfNoTests>
                    </configuration>
                </plugin>

                <!-- git -->
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <version>4.9.10</version>
                    <executions>
                        <execution>
                            <id>get-the-git-infos</id>
                            <goals>
                                <goal>revision</goal>
                            </goals>
                            <phase>initialize</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
                        <includeOnlyProperties>
                            <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
                            <includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
                        </includeOnlyProperties>
                        <!--<injectAllReactorProjects>true</injectAllReactorProjects>-->
                        <commitIdGenerationMode>full</commitIdGenerationMode>
                    </configuration>
                </plugin>

                <!-- scala -->
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>4.5.3</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>add-source</goal>
                                <goal>compile</goal>
                                <goal>doc-jar</goal>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <encoding>${character.encoding}</encoding>
                        <scalaVersion>${scala.version}</scalaVersion>
                        <recompileMode>incremental</recompileMode>
                        <args>
                            <arg>-deprecation</arg>
                            <arg>-explaintypes</arg>
                            <arg>-feature</arg>
                            <arg>-unchecked</arg>
                        </args>
                        <javacArgs>
                            <javacArg>-Xlint:unchecked</javacArg>
                            <javacArg>-Xlint:deprecation</javacArg>
                        </javacArgs>
                        <source>${jdk.version}</source>
                        <target>${jdk.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest-maven-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <filereports>StoysTestSuite.txt</filereports>
                        <stderr />
                        <environmentVariables>
                            <SPARK_LOCAL_IP>127.0.0.1</SPARK_LOCAL_IP>
                        </environmentVariables>
                        <systemProperties>
                            <spark.ui.enabled>false</spark.ui.enabled>
                            <spark.ui.showConsoleProgress>false</spark.ui.showConsoleProgress>
                        </systemProperties>
                    </configuration>
                    <executions>
                        <execution>
                            <id>scalatest-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.spurint.maven.plugins</groupId>
                    <artifactId>scala-cross-maven-plugin</artifactId>
                    <version>0.3.0</version>
                    <executions>
                        <execution>
                            <id>rewrite-pom</id>
                            <goals>
                                <goal>rewrite-pom</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- shade -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.2.4</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <shadedClassifierName>spark-shaded</shadedClassifierName>
                        <createDependencyReducedPom>true</createDependencyReducedPom>
                        <dependencyReducedPomLocation>
                            ${project.basedir}/target/dependency-reduced-pom.xml
                        </dependencyReducedPomLocation>
                        <artifactSet combine.children="append">
                            <includes>
                                <include>non-existent-dependency:forcing-shade-plugin-to-run</include>
                            </includes>
                        </artifactSet>
                        <filters>
                            <filter>
                                <artifact>*:*</artifact>
                                <excludes>
                                    <exclude>META-INF/maven/**</exclude>
                                    <exclude>META-INF/*.SF</exclude>
                                    <exclude>META-INF/*.DSA</exclude>
                                    <exclude>META-INF/*.RSA</exclude>
                                </excludes>
                            </filter>
                        </filters>
                        <relocations combine.children="append">
                            <relocation>
                                <pattern>com.fasterxml.jackson</pattern>
                                <shadedPattern>io.stoys.shaded.com.fasterxml.jackson</shadedPattern>
                            </relocation>
                            <relocation>
                                <pattern>org.log4s</pattern>
                                <shadedPattern>io.stoys.shaded.org.log4s</shadedPattern>
                            </relocation>
                        </relocations>
                        <transformers combine.children="append">
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>${main.class}</mainClass>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                        </transformers>
                    </configuration>
                </plugin>

                <!-- release -->
                <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>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.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.0</version>-->
                <!--    <configuration>-->
                <!--        <additionalparam>-Xdoclint:all -Xdoclint:-missing</additionalparam>-->
                <!--    </configuration>-->
                <!--    <executions>-->
                <!--        <execution>-->
                <!--            <id>attach-javadocs</id>-->
                <!--            <goals>-->
                <!--                <goal>jar</goal>-->
                <!--            </goals>-->
                <!--        </execution>-->
                <!--    </executions>-->
                <!--</plugin>-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                            <configuration>
                                <gpgArguments>
                                    <arg>--pinentry-mode</arg>
                                    <arg>loopback</arg>
                                </gpgArguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>3.0.0-M4</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <tagNameFormat>stoys-@{project.version}</tagNameFormat>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>java-8</id>
            <properties>
                <jdk.version>8</jdk.version>
            </properties>
        </profile>
        <profile>
            <id>java-11</id>
            <properties>
                <jdk.version>11</jdk.version>
            </properties>
        </profile>
        <profile>
            <id>java-15</id>
            <properties>
                <jdk.version>15</jdk.version>
            </properties>
        </profile>
        <profile>
            <id>scala-2.11</id>
            <properties>
                <scala.version>2.11.12</scala.version>
                <scala.compat.version>2.11</scala.compat.version>
            </properties>
        </profile>
        <profile>
            <id>scala-2.12</id>
            <properties>
                <scala.version>2.12.14</scala.version>
                <scala.compat.version>2.12</scala.compat.version>
            </properties>
        </profile>
        <profile>
            <id>scala-2.13</id>
            <properties>
                <scala.version>2.13.6</scala.version>
                <scala.compat.version>2.13</scala.compat.version>
                <scala-parallel-collections.version>1.0.3</scala-parallel-collections.version>
            </properties>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>org.scala-lang.modules</groupId>
                        <artifactId>scala-parallel-collections_${scala.compat.version}</artifactId>
                        <version>${scala-parallel-collections.version}</version>
                    </dependency>
                </dependencies>
            </dependencyManagement>
        </profile>
        <profile>
            <id>spark-2.4</id>
            <properties>
                <spark.version>2.4.8</spark.version>
            </properties>
        </profile>
        <profile>
            <id>spark-3.0</id>
            <properties>
                <spark.version>3.0.3</spark.version>
            </properties>
        </profile>
        <profile>
            <id>spark-3.1</id>
            <properties>
                <spark.version>3.1.2</spark.version>
            </properties>
        </profile>
        <profile>
            <id>spark-3.2</id>
            <properties>
                <spark.version>3.2.0-SNAPSHOT</spark.version>
            </properties>
            <repositories>
                <repository>
                    <id>apache.snapshots</id>
                    <url>https://repository.apache.org/snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>

        <profile>
            <id>disable-scalatest-examples</id>
            <activation>
                <property>
                    <name>!wildcardSuites</name>
                </property>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.scalatest</groupId>
                            <artifactId>scalatest-maven-plugin</artifactId>
                            <configuration>
                                <tagsToExclude>io.stoys.spark.test.Example</tagsToExclude>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>ossrh-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <!--<plugin>-->
                    <!--    <groupId>org.apache.maven.plugins</groupId>-->
                    <!--    <artifactId>maven-javadoc-plugin</artifactId>-->
                    <!--</plugin>-->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
            <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>
        </profile>
        <profile>
            <id>github-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <!--<plugin>-->
                    <!--    <groupId>org.apache.maven.plugins</groupId>-->
                    <!--    <artifactId>maven-javadoc-plugin</artifactId>-->
                    <!--</plugin>-->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
            <distributionManagement>
                <repository>
                    <id>github</id>
                    <name>GitHub Packages</name>
                    <url>https://maven.pkg.github.com/stoys-io/stoys</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>Central</id>
            <url>https://repo.maven.apache.org/maven2</url>
        </repository>
    </repositories>
</project>
