<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License 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. See accompanying LICENSE file.
-->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.apache.ozone</groupId>
    <artifactId>ozone</artifactId>
    <version>2.1.0</version>
  </parent>
  <artifactId>ozone-interface-client</artifactId>
  <version>2.1.0</version>
  <packaging>jar</packaging>
  <name>Apache Ozone Client Interface</name>
  <description>Apache Ozone Client interface</description>

  <properties>
    <!-- no tests in this module so far -->
    <maven.test.skip>true</maven.test.skip>
    <!-- only generated code in this module -->
    <spotbugs.skip>true</spotbugs.skip>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-api</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>jsr305</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>jsr305</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-stub</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop.thirdparty</groupId>
      <artifactId>${hadoop-thirdparty.protobuf.artifact}</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.ozone</groupId>
      <artifactId>hdds-interface-client</artifactId>
    </dependency>
    <dependency>
      <!-- for generated sources, Java 11+ -->
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-http2</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler-proxy</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>com.salesforce.servicelibs</groupId>
        <artifactId>proto-backwards-compatibility</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <proc>none</proc>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-proto-${protobuf2.version}</id>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
              <goal>compile-custom</goal>
              <goal>test-compile-custom</goal>
            </goals>
            <configuration>
              <protocArtifact>com.google.protobuf:protoc:${protobuf2.version}:exe:${os.detected.classifier}</protocArtifact>
              <outputDirectory>target/generated-sources/proto-java-protobuf-${protobuf2.version}</outputDirectory>
              <clearOutputDirectory>false</clearOutputDirectory>
              <pluginId>grpc-java</pluginId>
              <pluginArtifact>io.grpc:protoc-gen-grpc-java:${io.grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
            </configuration>
          </execution>
          <execution>
            <id>compile-proto-for-hadoop</id>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <protocArtifact>com.google.protobuf:protoc:${hadoop-thirdparty.protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
              <outputDirectory>target/generated-sources/proto-java-for-hadoop</outputDirectory>
              <clearOutputDirectory>false</clearOutputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>run</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <!-- use protobuf from hadoop-thirdparty -->
                <replace dir="target/generated-sources/proto-java-for-hadoop" token="com.google.protobuf" value="org.apache.hadoop.thirdparty.protobuf" />
                <!-- use matching hdds proto -->
                <replace dir="target/generated-sources/proto-java-for-hadoop" token="org.apache.hadoop.hdds.protocol.proto" value="org.apache.hadoop.hdds.protocol.hadoop_proto" />
                <!-- rename packages to avoid conflict -->
                <replace dir="target/generated-sources/proto-java-for-hadoop" token="org.apache.hadoop.ozone.protocol.proto" value="org.apache.hadoop.ozone.protocol.hadoop_proto" />
                <replace dir="target/generated-sources/proto-java-for-hadoop" token="org.apache.hadoop.ozone.security.proto" value="org.apache.hadoop.ozone.security.hadoop_proto" />
                <move file="target/generated-sources/proto-java-for-hadoop/org/apache/hadoop/ozone/protocol/proto" tofile="target/generated-sources/proto-java-for-hadoop/org/apache/hadoop/ozone/protocol/hadoop_proto" />
                <move file="target/generated-sources/proto-java-for-hadoop/org/apache/hadoop/ozone/security/proto" tofile="target/generated-sources/proto-java-for-hadoop/org/apache/hadoop/ozone/security/hadoop_proto" />
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
