<!--

    The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
    (the "License"). You may not use this work except in compliance with the License, which is
    available at www.apache.org/licenses/LICENSE-2.0

    This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
    either express or implied, as more fully set forth in the License.

    See the NOTICE file distributed with this work for information regarding copyright ownership.

-->
<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>
  <parent>
    <groupId>org.alluxio</groupId>
    <artifactId>alluxio-hub</artifactId>
    <version>2.7.0</version>
  </parent>
  <artifactId>alluxio-hub-transport</artifactId>
  <packaging>jar</packaging>
  <name>Alluxio Hub Transport</name>
  <description>Protobuf and gRPC definitions used by the Alluxio Hub</description>

  <properties>
    <!-- The following paths need to be defined here as well as in the parent pom so that mvn can -->
    <!-- run properly from sub-project directories -->
    <build.path>${project.parent.parent.basedir}/build</build.path>
    <failIfNoTests>false</failIfNoTests>
    <!-- The shading prefix should match the artifact ID, replacing '-' with '.' -->
    <shading.prefix>alluxio.hub.transport</shading.prefix>
    <skip.protoc>false</skip.protoc>
  </properties>

  <dependencies>
    <!-- External 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-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-stub</artifactId>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>generate</id>
      <properties>
        <skip.protoc>false</skip.protoc>
      </properties>
      <build>
        <plugins>
          <!-- Cleans the generated java files, prior to regenerating them from the proto/grpc definitions.  -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <configuration>
              <filesets>
                <fileset>
                  <directory>src/main/java/alluxio/proto</directory>
                  <followSymlinks>false</followSymlinks>
                  <includes>
                    <include>**/*.java</include>
                  </includes>
                </fileset>
                <fileset>
                  <directory>src/main/java/alluxio/grpc</directory>
                  <followSymlinks>false</followSymlinks>
                  <includes>
                    <include>**/*.java</include>
                  </includes>
                </fileset>
              </filesets>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>java11</id>
      <activation>
        <jdk>11</jdk>
      </activation>
      <dependencies>
        <dependency>
          <groupId>javax.annotation</groupId>
          <artifactId>javax.annotation-api</artifactId>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

  <build>
    <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>
        <executions>
          <execution>
            <id>java</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>compile</goal>
              <goal>compile-custom</goal>
            </goals>
            <configuration>
              <pluginId>grpc-java</pluginId>
              <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
              <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
              <skip>${skip.protoc}</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/generated-sources</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/resources</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Skip findbugs since there are only generated files in this module. -->
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      <!-- Skip checking licenses since there are only generated files in this module. -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      <!-- Skip checkstyle since there are only generated files in this module. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
