<?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/maven-v4_0_0.xsd">
  <parent>
    <artifactId>platform-parent</artifactId>
    <groupId>cz.o2.proxima</groupId>
    <version>0.2.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>io-pubsub</artifactId>
  <name>${project.groupId}:${project.artifactId}</name>
  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>1.4.1.Final</version>
      </extension>
    </extensions>
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.5.0</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
              <goal>compile-custom</goal>
            </goals>
          </execution>
        </executions>
        <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>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>Services shade</id>
            <phase>verify</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>${basedir}/shade-grpc-services.sh</executable>
              <arguments>
                <argument>${project.build.directory}/io-pubsub-${project.version}.jar</argument>
                <argument>io.grpc</argument>
                <argument>${shadePattern}.io.grpc</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>validate</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includes>**/META-INF/native/*</includes>
              <outputDirectory>${project.build.directory}/classes/</outputDirectory>
              <overWriteReleases>true</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.coderplus.maven.plugins</groupId>
        <artifactId>copy-rename-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
          <execution>
            <id>copy-and-rename-tcnative</id>
            <phase>compile</phase>
            <goals>
              <goal>rename</goal>
            </goals>
            <configuration>
              <fileSets>
                <fileSet>
                  <sourceFile>${project.build.directory}/classes/META-INF/native/libio_grpc_netty_shaded_netty_tcnative_linux_x86_64.so</sourceFile>
                  <destinationFile>${project.build.directory}/classes/META-INF/native/libcz_o2_proxima_pubsub_shaded_io_grpc_netty_shaded_netty_tcnative_linux_x86_64.so</destinationFile>
                </fileSet>
                <fileSet>
                  <sourceFile>${project.build.directory}/classes/META-INF/native/io_grpc_netty_shaded_netty_tcnative_windows_x86_64.dll</sourceFile>
                  <destinationFile>${project.build.directory}/classes/META-INF/native/cz_o2_proxima_pubsub_shaded_io_grpc_netty_shaded_netty_tcnative_windows_x86_64.dll</destinationFile>
                </fileSet>
                <fileSet>
                  <sourceFile>${project.build.directory}/classes/META-INF/native/libio_grpc_netty_shaded_netty_tcnative_osx_x86_64.jnilib</sourceFile>
                  <destinationFile>${project.build.directory}/classes/META-INF/native/libcz_o2_proxima_pubsub_shaded_io_grpc_netty_shaded_netty_tcnative_osx_x86_64.jnilib</destinationFile>
                </fileSet>
              </fileSets>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <artifactSet>
            <excludes>
              <exclude>cz.seznam.euphoria:*</exclude>
              <exclude>cz.o2.proxima:core</exclude>
            </excludes>
          </artifactSet>
          <shadeTestJar>true</shadeTestJar>
          <relocations>
            <relocation>
              <pattern>io.grpc.</pattern>
              <shadedPattern>${shadePattern}.io.grpc.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>io.opencensus.</pattern>
              <shadedPattern>${shadePattern}.io.opencensus.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.api.</pattern>
              <shadedPattern>${shadePattern}.com.google.api.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.pubsub.</pattern>
              <shadedPattern>${shadePattern}.com.google.pubsub.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.cloud.</pattern>
              <shadedPattern>${shadePattern}.com.google.cloud.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.auth.</pattern>
              <shadedPattern>${shadePattern}.com.google.auth.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.iam.</pattern>
              <shadedPattern>${shadePattern}.com.google.iam.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.common.</pattern>
              <shadedPattern>${shadePattern}.com.google.common.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.protobuf.</pattern>
              <shadedPattern>${shadePattern}.com.google.protobuf.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.fasterxml.</pattern>
              <shadedPattern>${shadePattern}.com.fasterxml.</shadedPattern>
            </relocation>
            <relocation>
              <pattern>cz.o2.proxima.storage.pubsub.proto.</pattern>
              <shadedPattern>cz.o2.proxima.storage.pubsub.internal.proto.</shadedPattern>
            </relocation>
          </relocations>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>cz.o2.proxima</groupId>
      <artifactId>core</artifactId>
      <version>0.2.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.16.16</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>cz.seznam.euphoria</groupId>
      <artifactId>euphoria-local</artifactId>
      <version>0.9-SNAPSHOT</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.7.25</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>log4j</artifactId>
          <groupId>log4j</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>hamcrest-core</artifactId>
          <groupId>org.hamcrest</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <version>1.10.19</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>3.0.2</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <properties>
    <shadePattern>cz.o2.proxima.pubsub.shaded</shadePattern>
  </properties>
</project>

