/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

apply plugin: 'elasticsearch.build'

dependencies {
  compileOnly project(':server')
  compileOnly project(':x-pack:plugin:esql:compute')
  compileOnly project(':x-pack:plugin:esql-core')
  compileOnly project(':x-pack:plugin:mapper-version')
  implementation('org.apache.arrow:arrow-vector:18.3.0')
  implementation('org.apache.arrow:arrow-format:18.3.0')
  implementation('org.apache.arrow:arrow-memory-core:18.3.0')
  implementation('org.checkerframework:checker-qual:3.42.0')
  implementation('com.google.flatbuffers:flatbuffers-java:23.5.26')
  // Needed for the json arrow serialization, and loaded even if we don't use it.
  implementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
  implementation("com.fasterxml.jackson.core:jackson-core:${versions.jackson}")
  implementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
  implementation("org.slf4j:slf4j-api:${versions.slf4j}")
  runtimeOnly "org.slf4j:slf4j-nop:${versions.slf4j}"

  testImplementation project(':test:framework')
  testImplementation('org.apache.arrow:arrow-memory-unsafe:18.3.0')
  testImplementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}")
}

tasks.named("dependencyLicenses").configure {
  mapping from: /jackson-.*/, to: 'jackson'
  mapping from: /arrow-.*/, to: 'arrow'
  mapping from: /slf4j-.*/, to: 'slf4j'
}

tasks.named("thirdPartyAudit").configure {
  ignoreViolations(
    // uses sun.misc.Unsafe. Only used in tests.
    'org.apache.arrow.memory.util.MemoryUtil',
    'org.apache.arrow.memory.util.MemoryUtil$1',
  )
  ignoreMissingClasses(
    'org.apache.commons.codec.binary.Hex'
  )
}

tasks.named("test").configure {
  jvmArgs('--add-opens=java.base/java.nio=ALL-UNNAMED')
}
