<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.geotab</groupId>
  <artifactId>java-sdk</artifactId>
  <version>5.7.2103.2</version>

  <name>java-sdk</name>
  <description>Geotab java sdk.</description>
  <url>https://www.geotab.com/</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
    <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
    <buildnumber-maven-plugin.version>1.4</buildnumber-maven-plugin.version>
    <maven-failsafe-plugin.version>3.0.0-M5</maven-failsafe-plugin.version>
    <mockserver.version>5.11.0</mockserver.version>
    <fasterxml.jackson.version>2.11.1</fasterxml.jackson.version>
    <apache.httpcomponents.version>5.0.1</apache.httpcomponents.version>
    <apache.commons.lang.version>3.10</apache.commons.lang.version>
    <slf4j.version>1.7.30</slf4j.version>
    <log4j.version>1.2.17</log4j.version>
    <log4j.jcl.version>2.13.3</log4j.jcl.version>
    <lombok.version>1.18.12</lombok.version>
    <guava.version>29.0-jre</guava.version>
    <junit.version>4.13</junit.version>
    <mockito.version>3.4.4</mockito.version>
    <junit-toolbox.version>2.4</junit-toolbox.version>
    <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
    <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
    <maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
    <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
    <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
    <skipTests>false</skipTests>
    <skipUnitTests>${skipTests}</skipUnitTests>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.httpcomponents.client5</groupId>
      <artifactId>httpclient5</artifactId>
      <version>${apache.httpcomponents.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${fasterxml.jackson.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>${fasterxml.jackson.version}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${fasterxml.jackson.version}</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${apache.commons.lang.version}</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.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>com.googlecode.junit-toolbox</groupId>
      <artifactId>junit-toolbox</artifactId>
      <version>${junit-toolbox.version}</version>
      <scope>test</scope>
    </dependency>


    <!-- add slf4j impl for test purpose; end users have the freedom to configure any implementation (log4j, log4j2, logback) -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>${slf4j.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>${log4j.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- mock server -->
    <dependency>
      <groupId>org.mock-server</groupId>
      <artifactId>mockserver-netty</artifactId>
      <version>${mockserver.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <!-- TODO: Use Sonar OR add some plugins like pmd, findbugs etc for code quality -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${maven-checkstyle-plugin.version}</version>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <configuration>
              <configLocation>quality-enforcement/checkstyle/google_checks.xml</configLocation>
              <encoding>UTF-8</encoding>
              <consoleOutput>true</consoleOutput>
              <failsOnError>true</failsOnError>
              <failOnViolation>true</failOnViolation>
              <!-- Exclude generated sources -->
              <sourceDirectories>
                <directory>${project.basedir}/src/main/java</directory>
              </sourceDirectories>
              <testSourceDirectories>
                <directory>${project.basedir}/src/test/java</directory>
              </testSourceDirectories>
            </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>

      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <groupId>org.apache.maven.plugins</groupId>
        <version>${maven-source-plugin.version}</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <groupId>org.apache.maven.plugins</groupId>
        <version>${maven-javadoc-plugin.version}</version>
        <configuration>
          <doclint>none</doclint>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <skipTests>${skipUnitTests}</skipTests>
        </configuration>
       </plugin>
    </plugins>
  </build>

  <licenses>
    <license>
      <name>Apache 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:https://git.geotab.com/dev/java-api-client</connection>
    <url>https://git.geotab.com/dev/java-api-client</url>
  </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>

  <developers>
    <developer>
      <name>Dragos Vizireanu-Isaic</name>
      <email>dragosvizireanuisaic@geotab.com</email>
      <organizationUrl>http://www.geotab.com</organizationUrl>
    </developer>
    <developer>
      <name>Atahan Ozer</name>
      <email>atahanozer@geotab.com</email>
      <organizationUrl>http://www.geotab.com</organizationUrl>
    </developer>
  </developers>

  <!--  this profile is used by build server   -->
  <!--  build server uses following mvn command to build:  
        mvn install -P build_server -Dbuild.output.path="<location of build output repo>" -Dbuild.revision="<git_commit_sha7]>"
   -->
  <profiles>
      <!-- Activate using the release property: mvn deploy -DskipTests -Prelease  -->
      <profile>
        <id>release</id>
        <activation>
          <property>
            <name>release</name>
          </property>
        </activation>

        <build>
          <plugins>
            <!-- To release to Maven central -->
            <plugin>
              <artifactId>nexus-staging-maven-plugin</artifactId>
              <groupId>org.sonatype.plugins</groupId>
              <version>${nexus-staging-maven-plugin.version}</version>
              <extensions>true</extensions>
              <configuration>
                <serverId>ossrh</serverId>
                <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                <autoReleaseAfterClose>false</autoReleaseAfterClose>
                <keepStagingRepositoryOnCloseRuleFailure>true</keepStagingRepositoryOnCloseRuleFailure>
              </configuration>
            </plugin>
            <!-- To generate javadoc -->
            <plugin>
              <artifactId>maven-source-plugin</artifactId>
              <groupId>org.apache.maven.plugins</groupId>
              <version>${maven-source-plugin.version}</version>
              <executions>
                <execution>
                  <id>attach-sources</id>
                  <goals>
                    <goal>jar-no-fork</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <artifactId>maven-javadoc-plugin</artifactId>
              <groupId>org.apache.maven.plugins</groupId>
              <version>${maven-javadoc-plugin.version}</version>
              <configuration>
                <doclint>none</doclint>
              </configuration>
              <executions>
                <execution>
                  <id>attach-javadocs</id>
                  <goals>
                    <goal>jar</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>

            <!-- To sign the artifacts -->
            <plugin>
              <artifactId>maven-gpg-plugin</artifactId>
              <groupId>org.apache.maven.plugins</groupId>
              <version>${maven-gpg-plugin.version}</version>
              <executions>
                <execution>
                  <id>sign-artifacts</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>sign</goal>
                  </goals>
                </execution>
              </executions>
              <configuration>
                <useAgent>true</useAgent>
                <gpgArguments>
                  <arg>--batch</arg>
                  <arg>--pinentry-mode</arg>
                  <arg>loopback</arg>
                </gpgArguments>
              </configuration>
            </plugin>
          </plugins>

        </build>
      </profile>

    <!--  runs integration tests against a real server to check model compatibility -->
    <profile>
      <id>compatibility</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <configuration>
              <includes>
                <include>**/compatibility/**/*CompatibilitySuiteIT.java</include>
              </includes>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
