<?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>0.9.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 -->
        <contrib.version>0.8.1</contrib.version>

        <grpc.version>1.12.0</grpc.version>
        <protoc.version>3.5.1</protoc.version> <!-- Same version as grpc-proto -->
        <slf4j.version>1.7.21</slf4j.version>
        <gson.version>2.7</gson.version> <!-- Same version as grpc-proto -->
        <mustache-java.version>0.9.4</mustache-java.version>
        <spring.version>4.2.0.RELEASE</spring.version>

        <!-- Test Dependency Versions -->
        <junit.version>4.12</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.7.5</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>

    <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.salesforce.servicelibs</groupId>
                <artifactId>grpc-contrib</artifactId>
                <version>${contrib.version}</version>
            </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-stub</artifactId>
                <version>${grpc.version}</version>
            </dependency>
            <dependency>
                <groupId>com.github.spullara.mustache.java</groupId>
                <artifactId>compiler</artifactId>
                <version>${mustache-java.version}</version>
            </dependency>
            <!-- Provided dependencies -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
                <scope>provided</scope>
            </dependency>
            <!-- Test dependencies -->
            <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>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.17</version>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>7.1.2</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>
        </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-javadoc-plugin</artifactId>
                        <version>2.10.4</version>
                        <configuration>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </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>

                    <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>

