<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">
  <parent>
    <groupId>org.opennms.plugins</groupId>
    <artifactId>opennms-es-rest.parent</artifactId>
    <version>22.0.0-SNAPSHOT</version>
  </parent>

  <!-- LicenceAuthenticator -->
  <modelVersion>4.0.0</modelVersion>
  <artifactId>opennms-es-rest.main-module</artifactId>
  <name>opennms-es-rest.main-module</name>
  <description>Main Module for opennms-es-rest</description>
  <packaging>bundle</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Bundle-Version>${project.version}</Bundle-Version>
            <Karaf-Commands>*</Karaf-Commands>
          </instructions>
        </configuration>
      </plugin>

      <!-- ElasticSearch maven plugin goals -->
      <!-- elasticsearch:help Display help information on elasticsearch-maven-plugin. -->
      <!-- Call mvn elasticsearch:help -Ddetail=true -Dgoal=<goal-name> to display parameter details. -->
      <!-- elasticsearch:load (phase: pre-integration-test) -->
      <!-- elasticsearch:stop (phase: post-integration-test) Goal which stops the local Elasticsearch node. -->
      <!-- elasticsearch:start (phase: pre-integration-test) Goal which starts a local Elasticsearch node. -->
      <!-- elasticsearch:run (phase: pre-integration-test) Starts a local instance of ElasticSearch indefinitely. -->
      <!-- In order to kill it a CTRL+C has to be made. -->
      <plugin>
        <groupId>com.github.alexcojocaru</groupId>
        <artifactId>elasticsearch-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <clusterName>test</clusterName>
          <!-- set not to clash with normal ES ports 9300 9200 -->
          <tcpPort>9300</tcpPort>
          <httpPort>9200</httpPort>
          <skip>${skipTests}</skip>
        </configuration>
        <executions>
          <!-- The elasticsearch plugin is by default bound to the -->
          <!-- pre-integration-test and post-integration-test phases -->
          <!-- here we are binding into the normal unit test phases -->
          <execution>
            <id>start-elasticsearch</id>
            <!-- <phase>pre-integration-test</phase> -->
            <phase>test-compile</phase>
            <goals>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>deploy-json</id>
            <!-- <phase>pre-integration-test</phase> -->
            <phase>test-compile</phase>
            <goals>
              <goal>load</goal>
            </goals>
            <configuration>
              <scriptFile>src/test/resources/elasticsearch.script</scriptFile>
            </configuration>
          </execution>
          <execution>
            <id>stop-elasticsearch</id>
            <!-- <phase>post-integration-test</phase> -->
            <phase>prepare-package</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <!-- REPLACE THE FOLLOWING WITH THE ES VERSION USED IN TESTS -->
            <version>2.4.0</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>

        <configuration>
          <excludes>
            <!-- prevent tests running in this package. These are manual one off development tests -->
            <exclude>**/manual/*.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>
                      com.github.alexcojocaru
                    </groupId>
                    <artifactId>
                      elasticsearch-maven-plugin
                    </artifactId>
                    <versionRange>[2.2,)</versionRange>
                    <goals>
                      <goal>start</goal>
                      <goal>load</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.opennms.plugins</groupId>
      <artifactId>org.opennms.plugin.licencemanager</artifactId>
      <version>${licencemanagerVersion}</version>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.karaf.shell</groupId>
      <artifactId>org.apache.karaf.shell.core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.karaf.shell</groupId>
      <artifactId>org.apache.karaf.shell.console</artifactId>
      <version>${karafVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.compendium</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-1.2-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- opennms dependencies -->
    <dependency>
      <groupId>org.opennms.osgi</groupId>
      <artifactId>opennms-osgi-core</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.opennms</groupId>
      <artifactId>opennms-dao</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.opennms.core</groupId>
      <artifactId>org.opennms.core.api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.opennms.core.ipc.sink</groupId>
      <artifactId>org.opennms.core.ipc.sink.common</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.opennms</groupId>
      <artifactId>opennms-model</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
      <version>${json-simpleVersion}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>io.searchbox</groupId>
      <artifactId>jest</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore-nio</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpasyncclient</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore-osgi</artifactId>
      <!-- <version>4.4.4</version> --><!-- jest version -->
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient-osgi</artifactId>
      <!-- <version>4.5.2</version> --><!-- jest version --> <!-- 4.3.6 best match -->
      <scope>provided</scope>
    </dependency>

    <!-- best match derived from httpasyncclient 4.0.2 compiled against httpclient 4.3.5 httpcore 4.3.2 -->
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpasyncclient-osgi</artifactId>
      <!-- <version>4.1.1</version> --><!-- jest version -->
      <scope>provided</scope>
    </dependency>

  </dependencies>

</project>
