<!--

    Copyright 2017-2020 O2 Czech Republic, a.s.

    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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>cz.o2.proxima</groupId>
  <artifactId>platform-parent</artifactId>
  <version>0.3.0-rc1</version>
  <packaging>pom</packaging>
  <inceptionYear>2017</inceptionYear>

  <name>${project.groupId}:${project.artifactId}</name>

  <description>Proxima platform is batch and realtime storage and data processing abstraction</description>
  <url>https://github.com/O2-Czech-Republic/proxima-platform</url>

  <developers>
    <developer>
      <id>je-ik</id>
      <name>Jan Lukavsky</name>
      <email>je.ik@seznam.cz</email>
      <roles>
        <role>architect</role>
        <role>developer</role>
      </roles>
      <timezone>Europe/Prague</timezone>
    </developer>
  </developers>

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

  <scm>
    <connection>scm:git:git@github.com:O2-Czech-Republic/proxima-platform.git</connection>
    <developerConnection>scm:git:git@github.com:O2-Czech-Republic/proxima-platform.git</developerConnection>
    <url>https://github.com/O2-Czech-Republic/proxima-platform.git</url>
    <tag>HEAD</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>
    <maven.shade.version>3.2.1</maven.shade.version>
    <groovy.version>2.5.9</groovy.version>
    <hadoop.version>2.10.0</hadoop.version>
    <hbase.version>1.5.0</hbase.version>
    <kafka.version>2.4.0</kafka.version>
    <proto.version>3.11.0</proto.version>
    <protoc.version>3.11.0</protoc.version>
    <grpc.version>1.25.0</grpc.version>
    <guava.version>28.1-jre</guava.version>
    <commons-io.version>2.6</commons-io.version>
    <license-maven-plugin.version>3.0</license-maven-plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <netty.version>4.1.42.Final</netty.version>
    <slf4j.version>1.7.30</slf4j.version>
    <argLine></argLine>
    <surefire.forkCount>8</surefire.forkCount>
    <!-- sonar config -->
    <jacoco.version>0.8.4</jacoco.version>
    <sonar.organization>datadriven</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <error-prone.version>2.3.3</error-prone.version>
    <coreShade>cz.o2.proxima.internal.shaded</coreShade>
    <lombok.version>1.18.10</lombok.version>
    <spotless.version>1.26.1</spotless.version>
  </properties>

  <profiles>
    <profile>
      <id>release</id>
      <properties>
        <!-- workaround of duplicate key: META-INF/services error -->
        <!-- works only locally, not to be used on any CI machine -->
        <maven.shade.version>3.2.2-SNAPSHOT</maven.shade.version>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>1.4.1</version>
            <executions>
              <execution>
                <id>enforce-no-snapshots</id>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requireReleaseDeps>
                      <message>No Snapshots Allowed!</message>
                    </requireReleaseDeps>
                  </rules>
                  <fail>true</fail>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
              <includePom>true</includePom>
            </configuration>
            <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-gpg-plugin</artifactId>
            <version>1.5</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>install</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.7</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>allow-snapshots</id>
      <repositories>
        <repository>
          <id>snapshots-repo</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
    </profile>
    <profile>
      <id>with-coverage</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <executions>
              <execution>
                <id>prepare-agent</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
              <execution>
                <id>report</id>
                <goals>
                  <goal>report</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>travis</id>
      <properties>
        <surefire.forkCount>1</surefire.forkCount>
      </properties>
    </profile>

    <profile>
      <!-- using github.com/google/error-prone-javac is required when running on JDK 8 -->
      <id>jdk8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <javac.version>9+181-r4173-1</javac.version>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <fork>true</fork>
              <compilerArgs combine.children="append">
                <arg>-J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${javac.version}/javac-${javac.version}.jar</arg>
              </compilerArgs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

  <build>

    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.4.1.Final</version>
      </extension>
    </extensions>

    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>8</source>
          <target>8</target>
          <forceJavacCompilerUse>true</forceJavacCompilerUse>
          <compilerArgs>
            <arg>-XDcompilePolicy=simple</arg>
            <!-- workaround of https://github.com/google/error-prone/issues/1321 -->
            <arg>-Xplugin:ErrorProne -Xep:ParameterName:OFF -Xep:UnusedVariable:OFF</arg>
            <arg>-Xlint:all</arg>
          </compilerArgs>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.errorprone</groupId>
              <artifactId>error_prone_core</artifactId>
              <version>${error-prone.version}</version>
            </path>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${lombok.version}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.2</version>
        <configuration>
          <forkCount>${surefire.forkCount}</forkCount>
          <reuseForks>false</reuseForks>
          <threadCount>1</threadCount>
          <parallel>suites</parallel>
          <useSystemClassLoader>true</useSystemClassLoader>
          <useManifestOnlyJar>false</useManifestOnlyJar>
          <argLine>@{argLine} -Xmx500m -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Dsun.io.serialization.extendedDebugInfo=true</argLine>
        </configuration>
      </plugin>

      <!-- help managing license headers -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${license-maven-plugin.version}</version>
        <configuration>
          <header>license-header.txt</header>
          <properties>
            <owner>O2 Czech Republic, a.s.</owner>
          </properties>
          <mapping>
            <proto>JAVADOC_STYLE</proto>
            <avsc>JAVADOC_STYLE</avsc>
            <Makefile>SCRIPT_STYLE</Makefile>
            <conf>JAVADOC_STYLE</conf>
          </mapping>
          <excludes>
            <exclude>**/license-header.txt</exclude>
            <exclude>**/license-header-spotless.txt</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>**/README</exclude>
            <exclude>**/LICENSE</exclude>
            <exclude>src/test/resources/**</exclude>
            <exclude>src/main/resources/**</exclude>
          </excludes>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin-git</artifactId>
            <version>${license-maven-plugin.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- javadoc -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>8</source>
        </configuration>
      </plugin>

      <!-- spotless -->
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>${spotless.version}</version>
        <configuration>
          <java>
             <googleJavaFormat>
               <!-- Optional, available versions: https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.google.googlejavaformat%22%20AND%20a%3A%22google-java-format%22 -->
               <version>1.6</version>
               <!-- Optional, available versions: GOOGLE, AOSP  https://github.com/google/google-java-format/blob/master/core/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java -->
               <style>GOOGLE</style>
             </googleJavaFormat>
             <removeUnusedImports />
             <licenseHeader>
               <file>${basedir}/license-header-spotless.txt</file>
             </licenseHeader>
             <!--importOrder>
               Specify either order or file, but not both
               <order>java,javax,org,com,com.diffplug,</order>
               <file>${basedir}/importOrder</file>
             </importOrder-->
          </java>
        </configuration>
        <executions>
          <execution>
            <id>apply</id>
            <phase>validate</phase>
            <goals>
              <goal>apply</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-all</artifactId>
        <version>${grpc.version}</version>
        <exclusions>
          <!-- do not use protobuf-lite, use protobuf-java -->
          <exclusion>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-lite</artifactId>
          </exclusion>
        </exclusions>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-core</artifactId>
        <version>${grpc.version}</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-protobuf</artifactId>
        <version>${grpc.version}</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-stub</artifactId>
        <version>${grpc.version}</version>
      </dependency>

      <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>${commons-io.version}</version>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
        <scope>test</scope>
      </dependency>

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

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.10.19</version>
        <scope>test</scope>
      </dependency>

    </dependencies>

  </dependencyManagement>

  <modules>
    <module>beam</module>
    <module>core</module>
    <module>direct</module>
    <module>example</module>
    <module>maven</module>
    <module>scheme</module>
    <module>tools</module>
  </modules>

</project>

