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

  <!--
    used a few sources to set up the pom so we can upload it to maven central
    1. https://dzone.com/articles/publish-your-artifacts-to-maven-central
    2. https://blog.10pines.com/2018/06/25/publish-artifacts-on-maven-central/
    Good doc for how to config the pom file can be found at: https://maven.apache.org/pom.html

    To deploy maven in remote, we will need to run 'mvn clean deploy'. More info about the deploy command at:
    https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html
   -->

  <groupId>io.amberflo</groupId>
  <artifactId>metering-java-client</artifactId>
  <name>Java metering client</name>
  <version>2.0.3</version>
  <packaging>jar</packaging>

  <description>A java client for the Amberflo's metering service</description>
  <url>https://www.amberflo.io/</url>

  <!-- More info regarding the different ways to sign your code:
   1. https://exygy.com/blog/which-license-should-i-use-mit-vs-apache-vs-gpl/ -->
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <!-- The SCM Plugin maps a lot of commands to a variety of scm implementations. But there are only 2 frequently
  used commands:
  1. checkin - commit the changes to the remote repository ( scm server ). For example
  "mvn scm:checkin -Dmessage='my message'" will do git add/commit/push.
  2. update - updates the local working copy with the one from the remote repository ( scm server ).
  More info at: https://maven.apache.org/scm/maven-scm-plugin/usage.html -->
  <scm>
    <connection>scm:git:git://github.com/amberflo/metering-java.git</connection>
    <developerConnection>scm:git:ssh://github.com:amberflo/metering-java.git</developerConnection>
    <url>https://github.com/amberflo/metering-java/tree/main/metering</url>
    <tag>HEAD</tag>
  </scm>

  <developers>
    <developer>
      <name>Ofer Shterling</name>
      <email>ofer@amberflo.io</email>
      <organization>Amberflo.io</organization>
      <organizationUrl>https://www.amberflo.io/</organizationUrl>
    </developer>
    <developer>
      <name>Mitarth Vaid</name>
      <email>mitarth@amberflo.io</email>
      <organization>Amberflo.io</organization>
      <organizationUrl>https://www.amberflo.io/</organizationUrl>
    </developer>
  </developers>

  <properties>
    <encoding>UTF-8</encoding>
    <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
    <project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>
    <project.resources.sourceEncoding>${encoding}</project.resources.sourceEncoding>
    <archetype.encoding>${encoding}</archetype.encoding>
  </properties>

<!-- Adding aws-sdk for S3metering client -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>bom</artifactId>
        <version>2.16.22</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>


  <dependencies>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.6</version>
    </dependency>
    <!-- https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/lambda-optimize-starttime.html -->
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3</artifactId>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.20</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.5</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>findbugs</artifactId>
      <scope>provided</scope>
      <version>3.0.1</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
      <version>4.13.1</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.burst</groupId>
      <artifactId>burst-junit4</artifactId>
      <scope>test</scope>
      <version>1.0.2</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.burst</groupId>
      <artifactId>burst</artifactId>
      <scope>test</scope>
      <version>1.0.2</version>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
      <version>2.0.0</version>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
      <version>2.21.0</version>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>${basedir}/src/main/java</sourceDirectory>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <forceJavacCompilerUse>true</forceJavacCompilerUse>
            <annotationProcessorPaths>
              <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.18.20</version>
              </path>
            </annotationProcessorPaths>
            <source>11</source>
            <target>11</target>
            <showWarnings>true</showWarnings>
          </configuration>
        </plugin>

        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>${spotless.version}</version>
          <configuration>
            <java>
              <googleJavaFormat>
                <version>1.5</version>
                <style>GOOGLE</style>
              </googleJavaFormat>
              <removeUnusedImports/>
            </java>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

    <!-- Info about the maven plugins: https://maven.apache.org/plugins/index.html -->
    <plugins>
      <!-- This plugin is used to release a project with Maven, saving a lot of repetitive, manual work.
      Releasing a project is made in two steps: prepare and perform.-->
      <!-- https://maven.apache.org/maven-release/maven-release-plugin/ -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>
        </configuration>
      </plugin>

      <!-- The report generated by this plugin is the result of executing the Cobertura tool against your compiled
      classes to help you determine how well the unit testing and integration testing efforts have been,
      and can then be used to identify which parts of your Java program are lacking test coverage.-->
      <!-- https://www.mojohaus.org/cobertura-maven-plugin/ -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          <formats>
            <format>html</format>
            <format>xml</format>
          </formats>
          <check />
        </configuration>
      </plugin>

      <!-- The Surefire Plugin has only one goal: surefire:test runs the unit tests of an application.-->
      <!-- https://maven.apache.org/surefire/maven-surefire-plugin/ -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
          <useSystemClassLoader>false</useSystemClassLoader>
        </configuration>
      </plugin>

      <!-- Attach source jars - exclude all files except to the readme -->
      <!-- https://maven.apache.org/plugins/maven-source-plugin/jar-mojo.html -->
      <!-- https://maven.apache.org/plugins/maven-source-plugin/usage.html -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <includes>
            <include>**/common/Logger.java</include>
          </includes>
        </configuration>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <!-- http://maven.apache.org/plugins/maven-source-plugin/jar-no-fork-mojo.html -->
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Attach javadocs jar -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <doclint>none</doclint>
        </configuration>
      </plugin>

      <!-- Create signatures for the artifacts and poms. -->
      <!-- https://central.sonatype.org/pages/working-with-pgp-signatures.html -->
      <!-- Notice that you also need to sign your pom file. See
      https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ for more info -->
      <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>
          </execution>
        </executions>
      </plugin>

      <!-- Creates a site for the proj: https://maven.apache.org/plugins/maven-site-plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>
        <configuration>
          <!-- To run your site locally exec the 'mvn site:run' command. This will start the website, which you can
          access at: http://localhost:9000. More info at:
          https://maven.apache.org/plugins/maven-site-plugin/examples/siterun.html -->
          <port>9000</port>
          <tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
          <locales>en</locales>
        </configuration>
      </plugin>
      <!-- needed for the maven site:
      https://stackoverflow.com/questions/51091539/maven-site-plugins-3-3-java-lang-classnotfoundexception-org-apache-maven-doxia-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>3.0.0</version>
      </plugin>

      <!-- Build an assembly (distribution) of sources and/or binaries. -->
      <!-- The Assembly Plugin for Maven enables developers to combine project output into a single distributable
      archive that also contains dependencies, modules, site documentation, and other files.-->
      <!-- https://maven.apache.org/plugins/maven-assembly-plugin/ -->
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>
                com.amberflo.metering.metering
              </mainClass>
            </manifest>
          </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <!-- A repository manager is a dedicated server application designed to manage repositories of binary components.
    The usage of a repository manager is considered an essential best practice for any significant usage of Maven.
    A repository manager act as dedicated proxy server for public Maven repositories and provide repositories as a
    deployment destination for your Maven project outputs. More info at:
    https://maven.apache.org/repository-management.html. We are using https://www.sonatype.com/nexus/repository-oss as
    the repository manager.-->
  <!-- Distribution management acts precisely as it sounds: it manages the distribution of the artifact and
  supporting files generated throughout the build process. -->
  <distributionManagement>
    <!-- Whereas the repositories element specifies in the POM the location and manner in which Maven may download
    remote artifacts for use by the current project, distributionManagement specifies where (and how) this project
    will get to a remote repository when it is deployed. The repository elements will be used for snapshot
    distribution if the snapshotRepository is not defined. -->
    <snapshotRepository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>sonatype-nexus-staging</id>
      <name>Nexus Release Repository</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
    </repository>
    <!-- Configure the site to be the local host (currently): https://maven.apache.org/plugins/maven-site-plugin/usage.html -->
  </distributionManagement>

  <!-- A new feature of the POM 4.0 is the ability of a project to change settings depending on the environment
  where it is being built. A profile element contains both an optional activation (a profile trigger) and the set
  of changes to be made to the POM if that profile has been activated. -->
  <profiles>
    <profile>
      <id>jdk-11-config</id>
      <activation>
        <jdk>11</jdk>
      </activation>
      <properties>
        <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
      </properties>
    </profile>
  </profiles>

  <!--
    Reporting contains the elements that correspond specifically for the site generation phase. Certain Maven
    plugins can generate reports defined and configured under the reporting element, for example: generating
    Javadoc reports (more info about the site command: https://maven.apache.org/plugins/maven-site-plugin/).
  -->
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.1</version>
        <reportSets>
          <reportSet>
            <id>html</id>
            <reports>
              <report>javadoc</report>
            </reports>
            <configuration>
              <show>public</show>
              <doclint>none</doclint>
              <excludePackageNames>*.internal:org.acme.exclude1.*:org.acme.exclude2</excludePackageNames>
              <additionalDependencies>
                <additionalDependency>
                  <groupId>com.google.code.gson</groupId>
                  <artifactId>gson</artifactId>
                  <version>2.8.6</version>
                </additionalDependency>
                <additionalDependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-api</artifactId>
                  <version>1.7.5</version>
                </additionalDependency>
              </additionalDependencies>
            </configuration>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>

</project>
