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

  <groupId>io.github.wechaty</groupId>
  <version>0.11.25</version>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>grpc</artifactId>
  <packaging>jar</packaging>
  <name>wechaty-grpc</name>

  <description>
    Wechaty is a Wechat Bot SDK for Personal Account that lets you create software to extend the functionality of the
    Wechat,
    writen in Node.js with TypeScript, Support all platforms including Linux, Windows, Darwin(OSX/Mac) and Docker.
  </description>
  <url>https://github.com/Chatie/grpc</url>

  <contributors>
    <contributor>
      <name>Zhengxin Diao</name>
      <email>diaozxin@gmail.com</email>
    </contributor>
  </contributors>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Zhengxin Diao</name>
      <email>diaozxin@gmail.com</email>
    </developer>
  </developers>


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

  <scm>
    <url>https://github.com/Chatie/grpc</url>
    <connection>scm:git:ssh://github.com/Chatie/grpc.git</connection>
    <developerConnection>scm:git:ssh://git@github.com/Chatie/grpc.git</developerConnection>
    <tag>HEAD</tag>
  </scm>

  <properties>
    <java.version>1.8</java.version>
    <kotlin.version>1.3.72</kotlin.version>
    <kotlinx.coroutines.version>1.3.4</kotlinx.coroutines.version>
    <grpc.version>1.25.0</grpc.version>
    <grpc.kotlin.version>0.1.1</grpc.kotlin.version>
    <protobuf.version>3.11.4</protobuf.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>${kotlin.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlinx</groupId>
      <artifactId>kotlinx-coroutines-core</artifactId>
      <version>${kotlinx.coroutines.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>${protobuf.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java-util</artifactId>
      <version>${protobuf.version}</version>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-netty-shaded</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>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>1.3.2</version>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-kotlin-stub</artifactId>
      <version>${grpc.kotlin.version}</version>
    </dependency>
  </dependencies>

  <build>
    <!--    <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>-->

    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.6.2</version>
      </extension>
    </extensions>

    <plugins>
      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.6.1</version>
        <configuration>
          <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
          <protoSourceRoot>${basedir}/proto/wechaty</protoSourceRoot>
        </configuration>
        <executions>
          <execution>
            <id>grpc-java</id>
            <goals>
              <goal>compile</goal>
              <goal>compile-custom</goal>
            </goals>
            <configuration>
              <pluginId>grpc-java</pluginId>
              <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
              </pluginArtifact>
              <protoSourceRoot>${basedir}/proto/wechaty</protoSourceRoot>
            </configuration>
          </execution>
          <execution>
            <id>grpc-kotlin</id>
            <goals>
              <goal>compile</goal>
              <goal>compile-custom</goal>
            </goals>
            <configuration>
              <pluginId>grpc-kotlin</pluginId>
              <pluginArtifact>io.grpc:protoc-gen-grpc-kotlin:${grpc.kotlin.version}:exe:${os.detected.classifier}
              </pluginArtifact>
              <protoSourceRoot>${basedir}/proto/wechaty</protoSourceRoot>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <version>${kotlin.version}</version>
        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <sourceDirs>
                <sourceDir>${project.build.directory}/generated-sources/protobuf/java/</sourceDir>
                <sourceDir>${project.build.directory}/generated-sources/protobuf/grpc-java/</sourceDir>
                <sourceDir>${project.build.directory}/generated-sources/protobuf/grpc-kotlin/</sourceDir>
              </sourceDirs>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <executions>
          <!-- 替换会被 maven 特别处理的 default-compile -->
          <execution>
            <id>default-compile</id>
            <phase>none</phase>
          </execution>
          <!-- 替换会被 maven 特别处理的 default-testCompile -->
          <execution>
            <id>default-testCompile</id>
            <phase>none</phase>
          </execution>

          <execution>
            <id>java-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>java</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.0.1</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</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>
            <configuration>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Javadoc -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
