<!--
  ~ Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License").
  ~ You may not use this file except in compliance with the License.
  ~ A copy of the License is located at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ or in the "license" file accompanying this file. This file 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>

    <modelVersion>4.0.0</modelVersion>
    <groupId>software.amazon.qldb</groupId>
    <artifactId>amazon-qldb-driver-java</artifactId>
    <version>2.3.1</version>
    <packaging>jar</packaging>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>
        A Java implementation of the Amazon QLDB driver that can be used to programmatically access and interact with data in Amazon QLDB ledgers.
    </description>
    <url>https://aws.amazon.com/qldb/</url>

    <scm>
        <connection>scm:git:https://github.com/awslabs/amazon-qldb-driver-java.git</connection>
        <developerConnection>scm:git:git@github.com:awslabs/amazon-qldb-driver-java.git</developerConnection>
        <url>https://github.com/awslabs/amazon-qldb-driver-java</url>
    </scm>

    <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>amazonwebservices</id>
            <organization>Amazon Web Services</organization>
            <organizationUrl>https://aws.amazon.com</organizationUrl>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

    <distributionManagement>
        <snapshotRepository>
            <id>maven</id>
            <url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>maven</id>
            <url>https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <aws.java.sdk.version>2.15.79</aws.java.sdk.version>
        <build.year>${maven.build.timestamp}</build.year>
        <checkstyle.version>8.29</checkstyle.version>
        <findbugs.maven.plugin.version>3.0.5</findbugs.maven.plugin.version>
        <ion.hash.version>1.0.0</ion.hash.version>
        <ion.version>1.8.0</ion.version>
        <jacoco.maven.plugin.version>0.8.5</jacoco.maven.plugin.version>
        <jdkVersion>1.8</jdkVersion>
        <junit.jupiter.migration.support.version>5.0.0-M4</junit.jupiter.migration.support.version>
        <junit.jupiter.version>5.6.2</junit.jupiter.version>
        <maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
        <maven.antrun.plugin.version>1.8</maven.antrun.plugin.version>
        <maven.build.timestamp.format>yyyy</maven.build.timestamp.format>
        <maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
        <maven.failsafe.plugin.version>2.22.0</maven.failsafe.plugin.version>
        <maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
        <maven.javadoc.plugin.version>2.10.3</maven.javadoc.plugin.version>
        <maven.jxr.plugin.verision>3.0.0</maven.jxr.plugin.verision>
        <maven.pmd.plugin.version>3.11.0</maven.pmd.plugin.version>
        <maven.site.plugin.version>3.7.1</maven.site.plugin.version>
        <maven.source.plugin.version>3.0.1</maven.source.plugin.version>
        <maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
        <mockito.core.version>3.3.3</mockito.core.version>
        <nexus.staging.maven.plugin.version>1.6.7</nexus.staging.maven.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <properties.maven.plugin.version>1.0.0</properties.maven.plugin.version>
        <slf4j.api.version>1.7.26</slf4j.api.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>apache-client</artifactId>
            <version>${aws.java.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>qldbsession</artifactId>
            <version>${aws.java.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazon.ion</groupId>
            <artifactId>ion-java</artifactId>
            <version>${ion.version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazon.ion</groupId>
            <artifactId>ion-hash-java</artifactId>
            <version>${ion.hash.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.api.version}</version>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.core.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>qldb</artifactId>
            <version>${aws.java.sdk.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${jdkVersion}</source>
                    <target>${jdkVersion}</target>
                </configuration>
            </plugin>
            <plugin>
                <!--
                Since the format of maven.build.timestamp cannot be changed
                during the build, define the build.time property here.
                -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>${maven.antrun.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <exportAntProperties>true</exportAntProperties>
                            <target>
                                <tstamp>
                                    <format property="build.time" pattern="yyyy-MM-dd'T'HH:mm:ssXXX"/>
                                </tstamp>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Run the unit tests. -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
            </plugin>
            <!-- Code Coverage -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <configuration>
                    <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
                    <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
                    <output>file</output>
                    <append>true</append>
                </configuration>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>COMPLEXITY</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.80</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven-checkstyle-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>${checkstyle.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>checkstyle</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <configLocation>./checkstyle.xml</configLocation>
                    <suppressionsLocation>./checkstyle-suppressions.xml</suppressionsLocation>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                    <logViolationsToConsole>true</logViolationsToConsole>
                    <failOnViolation>true</failOnViolation>
                    <excludes>**/module-info.java</excludes>
                </configuration>
            </plugin>
            <!-- Static Site generation with all reports -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>${maven.site.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>${properties.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>write-project-properties</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.build.outputDirectory}/version.properties</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <!-- select non-aggregate reports -->
                            <report>report</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>

            <plugin>
                <!-- Generate the Javadocs. -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven.javadoc.plugin.version}</version>
                <configuration>
                    <source>8</source>
                </configuration>
                <reportSets>
                    <reportSet>
                        <configuration>
                            <overview>${project.basedir}/src/software/amazon/qldb/overview.html</overview>
                            <doctitle>Amazon QLDB Java Driver ${project.version} API Reference</doctitle>
                            <windowtitle>Amazon QLDB Java Driver ${project.version}</windowtitle>
                            <header>Amazon QLDB Java Driver ${project.version} API Reference</header>
                            <encoding>UTF-8</encoding>
                            <bottom><![CDATA[<center>Copyright &#169; 2014&ndash;${build.year} Amazon.com. All Rights Reserved.</center>]]></bottom>
                            <name>Amazon QLDB Java Driver Javadoc</name>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                        <reports>
                            <report>javadoc-no-fork</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <!-- Findbugs -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>${findbugs.maven.plugin.version}</version>
            </plugin>
            <!-- PMD -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>${maven.pmd.plugin.version}</version>
                <configuration>
                    <linkXRef>true</linkXRef>
                    <sourceEncoding>utf-8</sourceEncoding>
                    <minimumTokens>100</minimumTokens>
                </configuration>
            </plugin>
            <!-- XLR to add links in reports to code -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>${maven.jxr.plugin.verision}</version>
            </plugin>
        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <!-- Package the source jar. -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven.source.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <excludes>
                                <exclude>**/*</exclude>
                            </excludes>
                            <excludeResources>true</excludeResources>
                            <forceCreation>true</forceCreation>
                        </configuration>
                    </plugin>
                    <plugin>
                        <!-- Package the javadoc jar. -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven.javadoc.plugin.version}</version>
                        <configuration>
                            <overview>${project.basedir}/src/software/amazon/qldb/overview.html</overview>
                            <doctitle>Amazon QLDB Java Driver ${project.version} API Reference</doctitle>
                            <windowtitle>Amazon QLDB Java Driver ${project.version}</windowtitle>
                            <header>Amazon QLDB Java Driver ${project.version} API Reference</header>
                            <encoding>UTF-8</encoding>
                            <bottom><![CDATA[<center>Copyright &#169; 2007&ndash;${build.year} Amazon.com. All Rights Reserved.</center>]]></bottom>
                            <name>Amazon QLDB Java Driver Javadoc</name>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <!-- GPG signing. -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven.gpg.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <!-- Publish the artifacts. -->
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus.staging.maven.plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>maven</serverId>
                            <nexusUrl>https://aws.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
