<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  Copyright (c) 2019, Salesforce.com, Inc.
  ~  All rights reserved.
  ~  Licensed under the BSD 3-Clause license.
  ~  For full license text, see LICENSE.txt file in the repo root  or https://opensource.org/licenses/BSD-3-Clause
  -->

<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.salesforce.servicelibs</groupId>
    <artifactId>jprotoc-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.2.1</version>

    <name>jProtoc</name>
    <description>A library for writing protobuf plugins in Java</description>
    <url>https://github.com/salesforce/grpc-java-contrib</url>

    <licenses>
        <license>
            <name>BSD 3-Clause License</name>
            <url>https://github.com/salesforce/grpc-java-contrib/blob/master/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>rmichela</id>
            <name>Ryan Michela</name>
            <email>rmichela@salesforce.com</email>
        </developer>
        <developer>
            <id>joeyb</id>
            <name>Joey Bratton</name>
            <email>jbratton@salesforce.com</email>
        </developer>
        <developer>
            <id>b-hoyt</id>
            <name>Ben Hoyt</name>
            <email>bhoyt@salesforce.com</email>
        </developer>
    </developers>

    <modules>
        <module>jprotoc</module>
        <module>jprotoc-test</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <gitRepo>scm:git:git@github.com:salesforce/grpc-java-contrib.git</gitRepo>
        <mavenRepoId>ossrh</mavenRepoId>
        <mavenBaseUrl>https://oss.sonatype.org/content/repositories</mavenBaseUrl>

        <!-- Dependency Versions -->
        <protoc.version>3.15.8</protoc.version>
        <gson.version>2.8.9</gson.version>
        <mustache-java.version>0.9.10</mustache-java.version>

        <!-- Test Dependency Versions -->
        <contrib.version>0.8.1</contrib.version>
        <grpc.version>1.37.0</grpc.version>
        <junit.version>4.13.1</junit.version>
        <assertj.version>3.6.2</assertj.version>
        <commons-lang.version>2.6</commons-lang.version>
        <awaitility.version>2.0.0</awaitility.version>
        <mockito.version>2.27.0</mockito.version>

        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
    </properties>

    <scm>
        <url>https://github.com/salesforce/grpc-java-contrib</url>
        <connection>${gitRepo}</connection>
        <developerConnection>${gitRepo}</developerConnection>
    </scm>

    <dependencies>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <!--
             ~ Where are Guava and Protobuf?
             ~ Due to the coupled nature between these contrib libraries and gRPC, the versions of Guava and Protobuf
             ~ need to be kept in lockstep with the versions used by gRPC. Declaring explicit dependencies on Guava and
             ~ Protobuf would require keeping them manually aligned with gRPC. Instead, Guava and Protobuf are
             ~ referenced transitively via gRPC itself.
            -->
            <dependency>
                <groupId>com.github.spullara.mustache.java</groupId>
                <artifactId>compiler</artifactId>
                <version>${mustache-java.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
            </dependency>
            <!-- Test dependencies -->
            <dependency>
                <groupId>com.salesforce.servicelibs</groupId>
                <artifactId>grpc-contrib</artifactId>
                <version>${contrib.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>io.grpc</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.salesforce.servicelibs</groupId>
                <artifactId>jprotoc</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-netty</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-core</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-api</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>io.grpc</groupId>
                <artifactId>grpc-stub</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.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>org.awaitility</groupId>
                <artifactId>awaitility</artifactId>
                <version>${awaitility.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>${commons-lang.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <compilerArgument>-Xlint:unchecked</compilerArgument>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.1.1</version>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>8.29</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <failsOnError>true</failsOnError>
                    <failOnViolation>true</failOnViolation>
                    <consoleOutput>true</consoleOutput>
                    <configLocation>../checkstyle.xml</configLocation>
                    <suppressionsLocation>../checkstyle_ignore.xml</suppressionsLocation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.9</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <author>false</author>
                    <breakiterator>true</breakiterator>
                    <doclint>accessibility,html,reference,syntax</doclint>
                    <keywords>true</keywords>
                    <version>false</version>
                    <source>8</source>
                </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.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>${mavenRepoId}</id>
            <url>${mavenBaseUrl}/releases</url>
        </repository>
        <snapshotRepository>
            <id>${mavenRepoId}</id>
            <url>${mavenBaseUrl}/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>public-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

