<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mapr.fs</groupId>
  <artifactId>libprotodefs</artifactId>
  <version>7.9.0.41-mapr</version>
  <parent>
    <groupId>com.mapr</groupId>
    <artifactId>mapr-release</artifactId>
    <version>7.9.0.41-mapr</version>
    <relativePath/>
  </parent>
  <name>MapR Protobuf Library</name>
  <url>http://www.mapr.com/</url>
  <repositories>
    <repository>
      <id>mapr-releases</id>
      <url>http://repository.mapr.com/maven/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-proto</id>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <property name="proto.src.dir" location="../fs/proto"/>
                <property name="rpc.proto.src.dir" location="../fs/rpc"/>
                <condition property="protoc.bin" value="${PROTOBUF_DIR}/bin/protoc" else="protoc">
                  <and>
                    <isset property="PROTOBUF_DIR"/>
                    <not>
                      <os family="windows"/>
                    </not>
                  </and>
                </condition>
                <condition property="protoc.bin" value="protoc.exe">
                  <os family="windows"/>
                </condition>
                <mkdir dir="${project.build.directory}/generated-sources"/>
                <apply executable="${protoc.bin}" failonerror="true">
                  <arg value="-I.."/>
                  <arg value="--proto_path=${rpc.proto.src.dir}"/>
                  <arg value="--java_out=${project.build.directory}/generated-sources"/>
                  <fileset dir="${rpc.proto.src.dir}" includes="                                                             hello.proto,                                                             rdma.proto,                                                             rpcadminserver.proto,                                                             rpcheader.proto"/>
                </apply>
                <apply executable="${protoc.bin}" failonerror="true">
                  <arg value="-I.."/>
                  <arg value="--proto_path=${proto.src.dir}"/>
                  <arg value="--java_out=${project.build.directory}/generated-sources"/>
                  <fileset dir="${proto.src.dir}" includes="                                                             accesscontrol.proto,                                                             billing.proto,                                                             cldb.proto,                                                             cldbs3server.proto,                                                             cli.proto,                                                             clustermetrics.proto,                                                             common.proto,                                                             dbfilters.proto,                                                             dbreplicator.proto,                                                             dbserver.proto,                                                             error.proto,                                                             fileserver.proto,                                                             gfsck.proto,                                                             gtrace.proto,                                                             iam.proto,                                                             iamconstants.proto                                                             license.proto,                                                             marlincommon.proto,                                                             marlinserver.proto,                                                             mastgateway.proto,                                                             metrics.proto,                                                             mfsoptions.proto,                                                             msicommon.proto,                                                             msiserver.proto,                                                             nfsmon.proto,                                                             orphan.proto,                                                             policyserver.proto,                                                             replicationserver.proto,                                                             security.proto,                                                             shmheader.proto,                                                             snapshotdb.proto,                                                             spserver.proto,                                                             tablemetrics.proto,                                                             volumemanager.proto,                                                             volumemirrorcommon.proto"/>
                </apply>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>copy-protodefs-jar-to-lib</id>
            <phase>install</phase>
            <configuration>
              <target>
                <copy file="${project.build.directory}/libprotodefs-${project.version}.jar" tofile="${project.basedir}/../../libs/libprotodefs-${project.version}.jar"/>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>clean-protodefs-jar-form-lib</id>
            <phase>clean</phase>
            <configuration>
              <target>
                <delete file="${project.basedir}/../../libs/libprotodefs-${project.version}.jar" quiet="true"/>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-proto</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>process-resources</phase>
            <configuration>
              <outputDirectory>${basedir}/target/classes/</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../fs/proto</directory>
                  <includes>
                    <include>clustermetrics.proto</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
