<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.exonum.binding</groupId>
  <artifactId>exonum-java-binding-parent</artifactId>
  <version>0.10.0</version>
  <packaging>pom</packaging>

  <name>Exonum Java Binding Parent</name>
  <description>
    The Exonum Java Binding library.
  </description>
  <!--TODO: change after the repo renaming-->
  <url>https://github.com/exonum/exonum-java-binding/tree/master/exonum-java-binding</url>
  <organization>
    <name>Exonum</name>
    <url>https://exonum.com/</url>
  </organization>
  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>dmitry-timofeev</id>
      <name>Dmitry Timofeev</name>
      <url>https://github.com/dmitry-timofeev</url>
    </developer>

    <developer>
      <id>MakarovS</id>
      <name>Sergei Makarov</name>
      <url>https://github.com/MakarovS</url>
    </developer>

    <developer>
      <id>bullet-tooth</id>
      <name>Oleg Bondar</name>
      <url>https://github.com/bullet-tooth</url>
    </developer>

    <developer>
      <id>vitvakatu</id>
      <name>Ilya Bogdanov</name>
      <url>https://github.com/vitvakatu</url>
    </developer>

    <developer>
      <id>skletsun</id>
      <name>Sergey Kletsun</name>
      <url>https://github.com/skletsun</url>
    </developer>
  </developers>

  <modules>
    <module>bom</module>
    <module>testing</module>
    <module>messages</module>
    <module>common</module>
    <module>core</module>
    <module>fake-service</module>
    <module>qa-service</module>
    <module>cryptocurrency-demo</module>
    <module>service-archetype</module>
    <module>time-oracle</module>
    <module>packaging</module>
    <module>testkit</module>
    <module>app</module>
    <module>integration-tests</module>
    <module>benchmarks</module>
    <module>site-examples</module>
  </modules>

  <scm>
    <connection>scm:git:https://github.com/exonum/exonum-java-binding.git</connection>
    <developerConnection>scm:git:git@github.com:/exonum/exonum-java-binding.git</developerConnection>
    <url>https://github.com/exonum/exonum-java-binding</url>
    <tag>HEAD</tag>
  </scm>
  <issueManagement>
    <system>github</system>
    <url>https://github.com/exonum/exonum-java-binding/issues</url>
  </issueManagement>
  <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>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.compiler.clientRelease>8</java.compiler.clientRelease>
    <java.compiler.frameworkRelease>11</java.compiler.frameworkRelease>
    <!--
    The default, most commonly used, release. It is overridden in the projects that require
    'client' version.
    -->
    <java.compiler.release>${java.compiler.frameworkRelease}</java.compiler.release>
    <!-- 11 is used for Javadoc sources, even for modules using 8, because we aggregate them
    in a single page. -->
    <javadoc.source>11</javadoc.source>
    <!-- Enables Java assertions, used in unit and integration tests -->
    <java.vm.assertionFlag>-ea:com.exonum.binding...</java.vm.assertionFlag>
    <!-- Skip generating Javadocs by default. Some profiles override this.  -->
    <maven.javadoc.skip>true</maven.javadoc.skip>
    <!-- Empty for all JDKs but 11 -->
    <maven.javadoc.joption></maven.javadoc.joption>

    <assertj.version>3.15.0</assertj.version>
    <checkstyle.configLocation>${project.basedir}/../checkstyle.xml</checkstyle.configLocation>
    <checkstyle.severity>warning</checkstyle.severity>
    <guice.version>4.2.3</guice.version>
    <log4j.version>2.13.1</log4j.version>
    <hamcrest.version>2.2</hamcrest.version>
    <junit.version>4.13</junit.version>
    <junit.jupiter.version>5.6.1</junit.jupiter.version>
    <protobuf.version>3.11.0</protobuf.version>
    <mockito.version>3.3.3</mockito.version>
    <guava.version>28.2-jre</guava.version>
    <vertx.version>3.9.0</vertx.version>
    <equalsverifier.version>3.1.13</equalsverifier.version>
    <javax-annotation-api.version>1.3.2</javax-annotation-api.version>
    <gson.version>2.8.6</gson.version>
    <auto-value-gson.version>1.3.0</auto-value-gson.version>
    <pf4j.version>3.2.0</pf4j.version>
    <os-maven-plugin.version>1.6.2</os-maven-plugin.version>
    <maven-assembly-plugin.version>3.2.0</maven-assembly-plugin.version>
    <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
    <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
    <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
    <maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version>
    <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
    <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    <protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>

    <!-- Default values of properties set by Jacoco when coverage is enabled.
         Passed to the JVM running tests. -->
    <jacoco.args></jacoco.args>
    <jacoco.it.args></jacoco.it.args>
    <jacoco.reports-path>${project.build.directory}/coverage-reports</jacoco.reports-path>
    <excludeTags>slow-test</excludeTags>
    <!-- Default build mode is `debug`, can also be `release`. Usually controlled
         by the packaging script (package_app.sh), but can also be set from the CLI -->
    <build.mode>debug</build.mode>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.jupiter.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${guava.version}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-bom</artifactId>
        <version>${log4j.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>${protobuf.version}</version>
      </dependency>

      <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>${gson.version}</version>
      </dependency>

      <dependency>
        <groupId>com.ryanharter.auto.value</groupId>
        <artifactId>auto-value-gson-runtime</artifactId>
        <version>${auto-value-gson.version}</version>
      </dependency>

      <!-- Basic support for Gson type adapters for AutoValue. -->
      <dependency>
        <groupId>com.ryanharter.auto.value</groupId>
        <artifactId>auto-value-gson-extension</artifactId>
        <version>${auto-value-gson.version}</version>
        <scope>provided</scope>
      </dependency>

      <!-- Support for TypeAdapter factories: https://github.com/rharter/auto-value-gson#factory -->
      <dependency>
        <groupId>com.ryanharter.auto.value</groupId>
        <artifactId>auto-value-gson-factory</artifactId>
        <version>${auto-value-gson.version}</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>org.pf4j</groupId>
        <artifactId>pf4j</artifactId>
        <version>${pf4j.version}</version>
      </dependency>

      <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest</artifactId>
        <version>${hamcrest.version}</version>
        <scope>test</scope>
      </dependency>

      <!-- An empty artifact, required while JUnit 4 is on the classpath to override its
           dependency on hamcrest.

           See http://hamcrest.org/JavaHamcrest/distributables#upgrading-from-hamcrest-1x
       -->
      <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>${hamcrest.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>nl.jqno.equalsverifier</groupId>
        <artifactId>equalsverifier</artifactId>
        <version>${equalsverifier.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-junit-jupiter</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${assertj.version}</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava-testlib</artifactId>
        <version>${guava.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <!-- Needed to fix @Generated annotation java 8 - 11 issue, Javadoc generation with JDK 9 -->
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>${javax-annotation-api.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- Shared test dependencies of all sub-modules. -->
    <!--JUnit5: junit-jupiter aggregates junit-jupiter-api and junit-jupiter-params +
        a runtime dependency on junit-jupiter-engine -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
          <configuration>
            <release>${java.compiler.release}</release>
            <showWarnings>true</showWarnings>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.xolstice.maven.plugins</groupId>
          <artifactId>protobuf-maven-plugin</artifactId>
          <version>${protobuf-maven-plugin.version}</version>
        </plugin>

        <!-- Checkstyle plugin is run during validate phase (before javac) -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>3.1.1</version>
          <configuration>
            <configLocation>${checkstyle.configLocation}</configLocation>
            <propertyExpansion>checkstyle.severity=${checkstyle.severity}</propertyExpansion>
            <linkXRef>false</linkXRef>
          </configuration>
          <executions>
            <execution>
              <id>check-java-code-style</id>
              <phase>validate</phase>
              <configuration>
                <encoding>UTF-8</encoding>
                <consoleOutput>true</consoleOutput>
                <failsOnError>true</failsOnError>
                <includeTestSourceDirectory>true</includeTestSourceDirectory>
              </configuration>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>8.19</version>
            </dependency>
          </dependencies>
        </plugin>

        <!-- Use newer version of the standard plugins by default. -->
        <plugin>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.0.0-M3</version>
        </plugin>

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
          <configuration>
            <redirectTestOutputToFile>true</redirectTestOutputToFile>
            <excludedGroups>
              ${excludeTags}
            </excludedGroups>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-failsafe-plugin.version}</version>
          <configuration>
            <redirectTestOutputToFile>true</redirectTestOutputToFile>
            <excludedGroups>
              ${excludeTags}
            </excludedGroups>
          </configuration>
        </plugin>

        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${maven-dependency-plugin.version}</version>
        </plugin>

        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </plugin>

        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>${maven-assembly-plugin.version}</version>
        </plugin>

        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>

        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>

        <!-- You may explicitly run `mvn spotbugs:spotbugs` from the command line,
             but it’s not bound to any phases in the default profile.
             See: https://spotbugs.readthedocs.io/en/latest/maven.html
           -->
        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>4.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>2.7</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.1.1</version>
          <configuration>
            <source>${javadoc.source}</source>
            <doclint>none</doclint>
            <detectOfflineLinks>false</detectOfflineLinks>
            <additionalJOption>${maven.javadoc.joption}</additionalJOption>
          </configuration>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </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-gpg-plugin</artifactId>
          <version>1.6</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>buildnumber-maven-plugin</artifactId>
          <version>1.4</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>check-build-prerequisites</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>[3.5,)</version>
                </requireMavenVersion>
                <requireJavaVersion>
                  <version>[11.,)</version>
                  <message>Java 11 is the minimum supported version.</message>
                </requireJavaVersion>
                <requireOS>
                  <!-- If we *do* support Windows and still rely on RUSTFLAGS (see the rule below
                       and 'tests_profile'), update the instructions. -->
                  <family>!windows</family>
                  <message>Java Binding cannot be built on Windows at the moment.
                    You are welcome to hack on ECR-446 and ECR-587!</message>
                </requireOS>
                <requireEnvironmentVariable>
                  <variableName>RUSTFLAGS</variableName>
                  <message>
                    RUSTFLAGS with proper runtime paths are required to run most integration tests.
                    Use 'source tests_profile' in your terminal to set the required
                    environment variables. See also CONTRIBUTING.md.
                  </message>
                </requireEnvironmentVariable>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- A build profile for a build performed on a CI server:
            - Fails if the code has style issues
            - Collects test coverage information
     -->
    <profile>
      <id>ci-build</id>
      <properties>
        <checkstyle.severity>error</checkstyle.severity>
        <jacoco.args>${argLine}</jacoco.args>
        <jacoco.it.args>${itCoverageAgent}</jacoco.it.args>
        <excludeTags>none</excludeTags>
      </properties>

      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.5</version>
            <configuration>
              <!-- Exclude the generated files from the coverage collection. -->
              <excludes>
                <exclude>**/*AutoValue*</exclude>
                <exclude>**/TxMessageProtos*</exclude>
                <exclude>**/WalletProtos*</exclude>
                <exclude>**/ServiceRuntimeProtos*</exclude>
                <exclude>**/DeployArguments*</exclude>
                <exclude>**/TestKitProtos*</exclude>
                <exclude>com/exonum/messages/**</exclude>
                <exclude>com/exonum/binding/fakeservice/Transactions*</exclude>
                <exclude>com/exonum/binding/qaservice/Config*</exclude>
                <exclude>com/exonum/binding/qaservice/transactions/TxMessageProtos*</exclude>
                <exclude>com/exonum/binding/common/messages/Service*</exclude>
              </excludes>
            </configuration>
            <executions>
              <execution>
                <id>prepare-jacoco-agent</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <destFile>${jacoco.reports-path}/jacoco-unit.exec</destFile>
                </configuration>
              </execution>
              <execution>
                <id>generate-jacoco-report</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <dataFile>${jacoco.reports-path}/jacoco-unit.exec</dataFile>
                </configuration>
              </execution>
              <execution>
                <id>prepare-jacoco-it-agent</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <destFile>${jacoco.reports-path}/jacoco-it.exec</destFile>
                  <propertyName>itCoverageAgent</propertyName>
                </configuration>
              </execution>
              <execution>
                <id>generate-jacoco-it-report</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>report-integration</goal>
                </goals>
                <configuration>
                  <dataFile>${jacoco.reports-path}/jacoco-it.exec</dataFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Profile used during deploy:
           - Generates Javadocs.
           - Signs the artefacts.
           - Deploys them to the remote repository. -->
    <profile>
      <id>deploy-sign-artifacts</id>
      <properties>
        <maven.javadoc.skip>false</maven.javadoc.skip>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <!--It is needed for correct gpg signing with gpg 2.1-->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <executions>
              <execution>
                <id>default-deploy</id>
                <phase>deploy</phase>
                <goals>
                  <goal>deploy</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Fill in needed property when generating Javadocs on JDK 11–12 -->
    <profile>
      <id>generate-javadocs-jdk11-12</id>
      <activation>
        <!-- Removed in 13 https://bugs.openjdk.java.net/browse/JDK-8215582-->
        <jdk>[11,13)</jdk>
      </activation>
      <properties>
        <maven.javadoc.joption>--no-module-directories</maven.javadoc.joption>
      </properties>
    </profile>
  </profiles>
</project>
