<?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">

  <parent>
    <groupId>org.opennms</groupId>
    <artifactId>org.opennms.features</artifactId>
    <version>23.0.0-SNAPSHOT</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.opennms.features</groupId>
  <artifactId>org.opennms.features.opennms-es-rest</artifactId>
  <name>OpenNMS :: Features :: ElasticSearch Rest</name>
  <description>${name}</description>
  <packaging>bundle</packaging>

  <properties>
    <json-simpleVersion>1.1.1</json-simpleVersion>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.searchbox</groupId>
        <artifactId>jest</artifactId>
        <version>${jestVersion}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <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>
      <plugin>
        <groupId>org.opennms.maven.plugins</groupId>
        <artifactId>features-maven-plugin</artifactId>
        <configuration>
          <name>opennms-es-rest</name>
          <features>
            <feature version="${project.version}">opennms-jest</feature>
          </features>
          <bundles>
            <!-- dropwizard-metrics feature -->
            <bundle>mvn:io.dropwizard.metrics/metrics-core/3.1.2</bundle>

            <!-- rate-limited-logger feature -->
            <bundle>mvn:joda-time/joda-time/${jodaTimeVersion}</bundle>
            <bundle>wrap:mvn:com.swrve/rate-limited-logger/${rateLimitedLoggerVersion}</bundle>

            <!-- opennms-core-ipc-sink-api feature -->
            <bundle>mvn:org.opennms.core.ipc.sink/org.opennms.core.ipc.sink.api/${project.version}</bundle>
            <bundle>mvn:org.opennms.core.ipc.sink/org.opennms.core.ipc.sink.common/${project.version}</bundle>
            <bundle>mvn:org.opennms.core.ipc.sink/org.opennms.core.ipc.sink.xml/${project.version}</bundle>

            <!-- actual plugin -->
            <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
          </bundles>
        </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>6.1</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>runforked</goal>
            </goals>
          </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>6.2.4</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>
  </build>

  <dependencies>
    <!-- actual dependencies (get added to features.xml) -->
    <dependency>
      <groupId>com.googlecode.json-simple</groupId>
      <artifactId>json-simple</artifactId>
      <version>${json-simpleVersion}</version>
    </dependency>
    <dependency>
      <groupId>org.opennms.core</groupId>
      <artifactId>org.opennms.core.cache</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- Provided Scope -->
    <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.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>org.opennms.features.jest</groupId>
      <artifactId>org.opennms.features.jest.client</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.searchbox</groupId>
      <artifactId>jest-complete-osgi</artifactId>
      <version>${jestVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${jestGsonVersion}</version>
      <scope>provided</scope>
    </dependency>

    <!-- Test Scope -->
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpasyncclient</artifactId>
      <version>${httpasyncclientVersion}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </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>
  </dependencies>

</project>
