<?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>
  <parent>
    <groupId>org.apache.hbase</groupId>
    <artifactId>hbase-local-hindex</artifactId>
    <version>2.4.14-h0.cbu.mrs.350.r26</version>
  </parent>

  <artifactId>hbase-hindex-protocol-shaded</artifactId>
  <name>Huawei HBase - Local Secondary Index Shaded Protocol</name>

  <properties>
    <maven.javadoc.skip>true</maven.javadoc.skip>
    <!--Version of protobuf that hbase uses internally (we shade our pb)
             Must match what is out in hbase-thirdparty include.
        -->
    <internal.protobuf.version>4.27.3</internal.protobuf.version>
  </properties>

  <dependencies>
    <!--BE CAREFUL! Any dependency added here needs to be
              excluded above in the shade plugin else the dependency
              will get bundled-->
    <!-- Intra-project dependencies -->
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-protocol-shaded</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.hbase.thirdparty</groupId>
      <artifactId>hbase-shaded-protobuf</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <!--Make it so assembly:single does nothing in here-->
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <skipAssembly>true</skipAssembly>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-protoc</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <protocExecutable>/opt/buildtools/protobuf-27.3/bin/protoc</protocExecutable>
              <checkStaleness>true</checkStaleness>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!--Need this old plugin to replace in generated files instances
                 of com.google.protobuf so instead its o.a.h.h.com.google.protobuf.
                 Plugin is old and in google code archive. Here is usage done by
                 anohther: https://github.com/beiliubei/maven-replacer-plugin/wiki/Usage-Guide
                 The mess with the regex in the below is to prevent replacement every time
                 we run mvn install. There is probably a better way of avoiding the
                 double interpolation but this is it for now.
              -->
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>1.5.3</version>
        <configuration>
          <basedir>${basedir}/target/generated-sources/</basedir>
          <includes>
            <include>**/*.java</include>
          </includes>
          <!-- Ignore errors when missing files, because it means this build
                           was run with -Dprotoc.skip and there is no -Dreplacer.skip -->
          <ignoreErrors>true</ignoreErrors>
          <replacements>
            <replacement>
              <token>([^\.])com.google.protobuf</token>
              <value>$1org.apache.hbase.thirdparty.com.google.protobuf</value>
            </replacement>
            <replacement>
              <token>(public)(\W+static)?(\W+final)?(\W+class)</token>
              <value>@javax.annotation.Generated("proto") $1$2$3$4</value>
            </replacement>
            <!-- replacer doesn't support anchoring or negative lookbehind -->
            <replacement>
              <token>(@javax.annotation.Generated\("proto"\) ){2}</token>
              <value>$1</value>
            </replacement>
          </replacements>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>replace</goal>
            </goals>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <!-- Skip the tests in this module -->
    <profile>
      <id>skip-protocol-shaded-tests</id>
      <activation>
        <property>
          <name>skip-protocol-shaded-tests</name>
        </property>
      </activation>
      <properties>
        <surefire.skipFirstPart>true</surefire.skipFirstPart>
        <surefire.skipSecondPart>true</surefire.skipSecondPart>
      </properties>
    </profile>
  </profiles>
</project>
