<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You 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.
-->
<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>
      <artifactId>storm</artifactId>
      <groupId>org.apache.storm</groupId>
      <version>1.2.1-mrs-2.1</version>
      <relativePath>../../pom.xml</relativePath>
  </parent>

  <groupId>org.apache.storm</groupId>
  <artifactId>storm-metrics</artifactId>
  <packaging>jar</packaging>

  <name>storm-metrics</name>

  <properties>
    <!-- settings for downloading the sigar native binary complete archive, which is not available in Maven central-->
    <sigar.version>1.6.4</sigar.version>
    <sigar.download.url>http://ei-nexus.inhuawei.com/nexus/content/groups/cloud_bdais-mrs-master-public/org/fusesource/sigar/${sigar.version}/hyperic-sigar-${sigar.version}.zip</sigar.download.url>
    <sigar.SHA1>05fc230a7b46cf8ff5cd73f0d05fd0578e96fb24</sigar.SHA1>
    <!-- this will download the sigar ZIP to the local maven repository next to the sigar dependencies,
         so we only download it once -->
    <sigar.download.path>${settings.localRepository}/org/fusesource/sigar/${sigar.version}</sigar.download.path>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.hdrhistogram</groupId>
      <artifactId>HdrHistogram</artifactId>
    </dependency>
    <dependency>
      <groupId>org.fusesource</groupId>
      <artifactId>sigar</artifactId>
      <version>${sigar.version}</version>
      <exclusions>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.storm</groupId>
      <artifactId>storm-core</artifactId>
      <version>${project.version}</version>
      <!-- keep storm out of the jar-with-dependencies -->
      <scope>${provided.scope}</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <id>prepare</id>
            <phase>validate</phase>
            <configuration>
              <tasks>
                <echo message="Downloading sigar native binaries..." />
                <get src="${sigar.download.url}" dest="${sigar.download.path}/" skipExisting="true" />
                <checksum file="${sigar.download.path}/hyperic-sigar-${sigar.version}.zip" algorithm="SHA1" property="${sigar.SHA1}" verifyProperty="validChecksum" />
                <fail message="Checksum validation failed for hyperic-sigar-${sigar.version}.zip">
                  <condition>
                    <isfalse value="${validChecksum}" />
                  </condition>
                </fail>
                <unzip src="${sigar.download.path}/hyperic-sigar-${sigar.version}.zip" dest="${project.build.directory}/classes/resources">
                  <patternset>
                    <include name="**/lib/libsigar-*" />
                    <include name="**/lib/sigar-*" />
                  </patternset>
                  <mapper type="flatten" />
                </unzip>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
