/*
 * 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.
 */

apply plugin: 'java-library'

description = 'Apache Solr Core'

dependencies {
  api platform(project(":platform"))
  permitUnusedDeclared platform(project(":platform"))
  // Spotbugs Annotations are only needed for old findbugs
  // annotation usage like in Zookeeper during compilation time.
  // It is not included in the release so exclude from checks.
  compileOnly libs.spotbugs.annotations
  testCompileOnly libs.spotbugs.annotations
  permitUnusedDeclared libs.spotbugs.annotations
  // Exclude these from jar validation and license checks.
  configurations.jarValidation {
    exclude group: "com.github.spotbugs", module: "spotbugs-annotations"
  }

  implementation libs.swagger3.annotations.jakarta

  // Export these dependencies so that they're imported transitively by
  // other modules.

  // These Lucene modules are the most significant to Solr
  api libs.apache.lucene.core
  api libs.apache.lucene.analysis.common
  api libs.apache.lucene.queries

  // We export logging api with dependencies, which is useful for all modules
  api libs.slf4j.api

  api project(':solr:api')
  api project(':solr:solrj')
  api project(':solr:solrj-zookeeper')
  api project(':solr:solrj-streaming')

  api libs.dropwizard.metrics.core
  implementation (libs.dropwizard.metrics.graphite, {
    exclude group: "com.rabbitmq", module: "amqp-client"
  })
  implementation libs.dropwizard.metrics.jmx
  implementation libs.dropwizard.metrics.jvm

  implementation(libs.jersey.containers.jettyhttp, {
    exclude group: "org.eclipse.jetty", module: "jetty-continuation"
    exclude group: "org.glassfish.hk2.external", module: "jakarta.inject"
  })
  permitUnusedDeclared libs.jersey.containers.jettyhttp
  implementation libs.jersey.inject.hk2
  permitUnusedDeclared libs.jersey.inject.hk2
  implementation (libs.jersey.media.jsonjackson, {
    exclude group: "jakarta.xml.bind", module: "jakarta.xml.bind-api"
  })
  permitUnusedDeclared libs.jersey.media.jsonjackson
  implementation libs.jersey.core.common
  implementation libs.jersey.core.server
  implementation libs.hk2.api
  implementation libs.jakarta.inject.api
  implementation libs.jakarta.ws.rsapi
  implementation libs.jakarta.annotation.api

  // Non-API below; although there are exceptions

  runtimeOnly libs.apache.lucene.analysis.kuromoji
  runtimeOnly libs.apache.lucene.analysis.nori
  runtimeOnly libs.apache.lucene.analysis.phonetic
  runtimeOnly libs.apache.lucene.backward.codecs
  implementation libs.apache.lucene.codecs
  implementation libs.apache.lucene.backward.codecs
  permitUnusedDeclared libs.apache.lucene.backward.codecs
  implementation libs.apache.lucene.classification
  implementation libs.apache.lucene.expressions
  implementation libs.apache.lucene.grouping
  implementation libs.apache.lucene.highlighter
  implementation libs.apache.lucene.join
  implementation libs.apache.lucene.misc
  implementation libs.apache.lucene.queryparser
  implementation libs.apache.lucene.sandbox
  implementation libs.apache.lucene.spatialextras
  implementation libs.apache.lucene.suggest


  // Collections & lang utilities
  implementation libs.google.guava
  implementation libs.apache.commons.lang3
  implementation libs.apache.commons.math3
  implementation libs.commonsio.commonsio
  implementation libs.carrotsearch.hppc

  implementation(libs.benmanes.caffeine) { transitive = false }

  implementation libs.commonscodec.commonscodec

  implementation libs.commonscli.commonscli

  implementation libs.locationtech.spatial4j

  implementation libs.fasterxml.jackson.core.annotations
  implementation libs.fasterxml.jackson.core.core
  implementation libs.fasterxml.jackson.core.databind
  implementation libs.fasterxml.jackson.dataformat.smile
  implementation libs.fasterxml.jackson.dataformat.cbor

  implementation libs.eclipse.jetty.client
  implementation libs.eclipse.jetty.http
  implementation libs.eclipse.jetty.io
  implementation libs.eclipse.jetty.toolchain.servletapi
  implementation libs.eclipse.jetty.util

  // ZooKeeper

  implementation(libs.apache.curator.framework, {
    exclude group: 'org.apache.zookeeper', module: 'zookeeper'
  })
  implementation(libs.apache.curator.client, {
    exclude group: 'org.apache.zookeeper', module: 'zookeeper'
  })
  testImplementation(libs.apache.curator.test, {
    exclude group: 'org.apache.zookeeper', module: 'zookeeper'
  })
  implementation(libs.apache.zookeeper.zookeeper, {
    exclude group: "org.apache.yetus", module: "audience-annotations"
  })
  implementation(libs.apache.zookeeper.jute) {
    exclude group: 'org.apache.yetus', module: 'audience-annotations'
  }
  testImplementation variantOf(libs.apache.zookeeper.zookeeper) { classifier 'tests' }

  // required for instantiating a Zookeeper server (for embedding ZK or running tests)
  runtimeOnly libs.xerial.snappy.java

  implementation(libs.jayway.jsonpath, {
    exclude group: "net.minidev", module: "json-smart"
  })

  // StatsComponents percentiles
  implementation libs.tdunning.tdigest

  // Distributed Tracing
  api libs.opentelemetry.api // Tracer is exposed on some methods
  implementation libs.opentelemetry.context

  implementation libs.apache.commons.exec

  implementation libs.apache.log4j.api
  implementation libs.apache.log4j.core
  runtimeOnly libs.apache.log4j.slf4j2impl

  // For the PrometheusResponseWriter
  implementation libs.prometheus.metrics.model
  implementation(libs.prometheus.metrics.expositionformats, {
    exclude group: "io.prometheus", module: "prometheus-metrics-shaded-protobuf"
    exclude group: "io.prometheus", module: "prometheus-metrics-config"
  })

  // For faster XML processing than the JDK
  implementation libs.codehaus.woodstox.stax2api
  implementation libs.fasterxml.woodstox.core
  // See https://issues.apache.org/jira/browse/LOG4J2-3609 due to needing these annotations
  compileOnly libs.aqute.bnd.annotation
  compileOnly libs.osgi.annotation

  compileOnly libs.stephenc.jcip.annotations

  implementation libs.j256.simplemagic

  // -- Test Dependencies

  testRuntimeOnly libs.slf4j.jcloverslf4j

  testRuntimeOnly libs.apache.lucene.analysis.icu

  testRuntimeOnly project(':solr:modules:analysis-extras')

  testImplementation project(':solr:core')
  testImplementation project(':solr:test-framework')

  testImplementation libs.apache.lucene.testframework

  testImplementation libs.eclipse.jetty.server
  testImplementation libs.eclipse.jetty.ee10.servlet
  testImplementation libs.eclipse.jetty.util
  testImplementation libs.jakarta.servlet.api
  testImplementation libs.carrotsearch.randomizedtesting.runner
  testImplementation libs.junit.junit
  testImplementation libs.hamcrest.hamcrest

  testImplementation(libs.mockito.core, {
    exclude group: "net.bytebuddy", module: "byte-buddy-agent"
  })
  testRuntimeOnly(libs.mockito.subclass, {
    exclude group: "net.bytebuddy", module: "byte-buddy-agent"
  })
  testImplementation libs.apache.httpcomponents.httpclient
  testImplementation libs.apache.httpcomponents.httpcore
}
