<?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/maven-v4_0_0.xsd ">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.jackrabbit</groupId>
    <artifactId>oak-parent</artifactId>
    <version>1.58.0</version>
    <relativePath>../oak-parent/pom.xml</relativePath>
  </parent>

  <artifactId>oak-search-elastic</artifactId>
  <name>Oak Elasticsearch</name>
  <packaging>bundle</packaging>
  <description>Oak Elasticsearch integration subproject</description>

  <properties>
    <elasticsearch.hlrc.version>7.17.13</elasticsearch.hlrc.version>
    <elasticsearch.java.client.version>8.7.1</elasticsearch.java.client.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <instructions combine.self="override">
            <_exportcontents>
              org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexProviderService
            </_exportcontents>
            <Import-Package>
              !jdk.net.*,
              !org.apache.avalon.framework.logger.*,
              !org.apache.log.*,
              !org.apache.logging.*,
              !org.elasticsearch.geometry.*,
              !org.joda.convert.*,
              !org.locationtech.jts.geom.*,
              !org.locationtech.spatial4j.*,
              !sun.misc.*,
              !org.apache.lucene.search.similarity.*,
              !org.apache.lucene.analysis.*,
              !org.glassfish.json.*,
              !com.sun.management.*,
              !joptsimple.*,
              !org.apache.lucene.search.suggest.document.*,
              !jakarta.json.bind.*,
              !com.carrotsearch.randomizedtesting.*,
              !org.yaml.snakeyaml.*,
              *
            </Import-Package>
            <Embed-Dependency>
              oak-search;scope=compile|runtime;inline=true,
              elasticsearch;groupId=org.elasticsearch,
              *;scope=compile|runtime
            </Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>
            <!-- needed to override value from oak-parent; can be removed when OAK-6741 is resolved -->
            <_plugin />
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/test.rtf</exclude>
            <exclude>**/test.txt</exclude>
            <exclude>**/fvs.csv</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <!-- Optional OSGi dependencies, used only when running within OSGi -->
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi.core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.component</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.scr.annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.component.annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>org.osgi.service.metatype.annotations</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Elastic/Lucene -->
    <dependency>
      <groupId>org.elasticsearch.client</groupId>
      <artifactId>elasticsearch-rest-high-level-client</artifactId>
      <version>${elasticsearch.hlrc.version}</version>
    </dependency>
    <dependency>
      <groupId>org.elasticsearch.client</groupId>
      <artifactId>elasticsearch-rest-client</artifactId>
      <version>${elasticsearch.hlrc.version}</version>
    </dependency>
	<dependency>
      <groupId>co.elastic.clients</groupId>
      <artifactId>elasticsearch-java</artifactId>
      <version>${elasticsearch.java.client.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>${elasticsearch.hlrc.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.elasticsearch</groupId>
          <artifactId>elasticsearch-cli</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.elasticsearch</groupId>
          <artifactId>elasticsearch-geo</artifactId>
        </exclusion>

        <!-- https://github.com/elastic/elasticsearch/issues/29184#issuecomment-662480046 -->
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-backward-codecs</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-grouping</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-memory</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-misc</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-queryparser</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-sandbox</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-spatial</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-spatial-extras</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-spatial3d</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-suggest</artifactId>
        </exclusion>
        <!--
          elasticsearch-xcontent depends on snakeyaml 1.33 which is vulnerable to remote code execution
          (https://nvd.nist.gov/vuln/detail/CVE-2022-1471)
          elasticsearch-xcontent is used in this module but only with the json parser which does not use snakeyaml
          so we can safely exclude it.
          This exclusion, like the others above, can be removed once we will remove the elasticsearch high level rest client
        -->
        <exclusion>
          <groupId>org.yaml</groupId>
          <artifactId>snakeyaml</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-parsers</artifactId>
      <version>${tika.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-shaded-guava</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-api</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-core-spi</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-store-spi</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-query-spi</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-core</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-search</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-jcr</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Nullability annotations -->
    <dependency>
      <groupId>org.jetbrains</groupId>
      <artifactId>annotations</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Test Dependencies -->
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-core</artifactId>
      <version>${project.version}</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-security-spi</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.service.event</artifactId>
       <scope>test</scope>
    </dependency>
    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.service.log</artifactId>
       <scope>test</scope>
    </dependency>
    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.service.cm</artifactId>
       <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>toxiproxy</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-jcr</artifactId>
      <version>${project.version}</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-search</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>oak-commons</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.stefanbirkner</groupId>
      <artifactId>system-rules</artifactId>
      <version>1.19.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
