<?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.hedera.hashgraph</groupId>
    <artifactId>hedera-protobuf-java-api</artifactId>
    <packaging>jar</packaging>
    <version>0.2.1</version>

    <name>hedera-protobuf-java-api</name>
  	<description>Protobuf Java API for Hedera Hashgraph</description>
  	<url>http://www.hedera.com</url>

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

  	<developers>
  		<developer>
  			<organization>Hedera Hashgraph</organization>
  			<organizationUrl>http://www.hedera.com</organizationUrl>
  		</developer>
  	</developers>

  	<scm>
  		<connection>scm:git:git://github.com/hashgraph/hedera-protobuf.git</connection>
  		<developerConnection>scm:git:git://github.com/hashgraph/hedera-protobuf.git</developerConnection>
  		<url>https://github.com/hashgraph/hedera-protobuf</url>
  	</scm>

  	<distributionManagement>
  		<snapshotRepository>
  			<id>ossrh-snapshots</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>

    <properties>
        <app.name>hedera-protobuf-java-api</app.name>
        <log4j-version>2.8.2</log4j-version>
        <grpc.version>1.17.1</grpc.version>
        <os.plugin.version>1.6.2</os.plugin.version>
        <protobuf.plugin.version>0.6.1</protobuf.plugin.version>
        <protoc.version>3.5.1</protoc.version>
    </properties>

    <dependencies>
        <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-stub</artifactId>
            <version>${grpc.version}</version>
        </dependency>

        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-testing</artifactId>
            <version>${grpc.version}</version>
        </dependency>


        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.5.1</version>
        </dependency>

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

		<dependency>
			<groupId>net.i2p.crypto</groupId>
			<artifactId>eddsa</artifactId>
			<version>0.3.0</version>
		</dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.11</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j-version}</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
            <version>2.8.2</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src/main/java</sourceDirectory>

      <!-- definition of the used plugins and their version -->
      <pluginManagement>
          <plugins>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>3.8.0</version>
              </plugin>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-javadoc-plugin</artifactId>
                  <version>3.0.1</version>
              </plugin>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <version>2.19.1</version>
              </plugin>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-deploy-plugin</artifactId>
                  <version>2.7</version>
              </plugin>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-source-plugin</artifactId>
                  <version>3.0.1</version>
              </plugin>
          </plugins>
      </pluginManagement>

      <!-- applying plugins to the maven build -->
<plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.source}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>${app.name}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <!--  JAVADOC local -->
      			<plugin>
      				<groupId>org.apache.maven.plugins</groupId>
      				<artifactId>maven-javadoc-plugin</artifactId>
      				<configuration>
      					<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
      					<additionalOptions>-html5</additionalOptions>
      					<reportOutputDirectory>${project.basedir}/javadoc</reportOutputDirectory>
      				</configuration>
      				<executions>
      					<execution>
      						<phase>install</phase>
      						<id>attach-javadocs</id>
      						<goals>
      							<goal>javadoc</goal>
      						</goals>
      					</execution>
      				</executions>
      			</plugin>

            <plugin>
      				<artifactId>maven-deploy-plugin</artifactId>
      				<configuration>
      					<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
      				</configuration>
      				<executions>
      					<execution>
      						<id>default-deploy</id>
      						<phase>deploy</phase>
      						<goals>
      							<goal>deploy</goal>
      						</goals>
      					</execution>
      				</executions>
      			</plugin>

            <plugin>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>${os.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>${protobuf.plugin.version}</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
                    </protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
                    </pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
            </extension>
        </extensions>
    </build>
	<reporting>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-project-info-reports-plugin</artifactId>
				<version>2.8</version>
				<configuration>
					<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
				</configuration>
			</plugin>
		</plugins>
	</reporting>
    <profiles>
        <!-- Depploy profile which adds the possibility to distribute the .jar to a remote repository
        Call "mvn clean deploy -Pdeploy" to invoke this additional plugin in the maven build
        this may fail because the javadocs jar isn't being signed automatically, in which case from the
        target folder, run  gpg2 -ab hedera-protobuf-java-api-0.2.0-javadoc then mvn deploy -Pdeploy
        Then manually upload to staging repository-->
        <profile>
            <id>deploy</id>
			<properties>
				<gpg.executable>gpg2</gpg.executable>
			</properties>
			<build>
				<plugins>
					<!--  JAVADOC JAR -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-javadoc-plugin</artifactId>
						<configuration>
							<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
							<additionalOptions>-html5</additionalOptions>
							<reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
						</configuration>
						<executions>
							<execution>
							<phase>deploy</phase>
								<id>attach-javadocs</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>
						<configuration>
							<skip>false</skip>
						</configuration>
						<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>
