apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
// Necessary to use tests in Serverless
apply plugin: 'elasticsearch.internal-test-artifact'
apply plugin: org.elasticsearch.gradle.internal.precommit.CheckstylePrecommitPlugin
apply plugin: org.elasticsearch.gradle.internal.precommit.ForbiddenApisPrecommitPlugin
apply plugin: org.elasticsearch.gradle.internal.precommit.ForbiddenPatternsPrecommitPlugin
apply plugin: org.elasticsearch.gradle.internal.precommit.FilePermissionsPrecommitPlugin
apply plugin: org.elasticsearch.gradle.internal.precommit.LoggerUsagePrecommitPlugin
apply plugin: org.elasticsearch.gradle.internal.precommit.TestingConventionsPrecommitPlugin

dependencies {
  javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
  javaRestTestImplementation project(xpackModule('esql:qa:server'))
  javaRestTestImplementation project(xpackModule('esql:tools'))
  javaRestTestImplementation project(xpackModule('esql'))
  yamlRestTestImplementation project(xpackModule('esql:qa:server'))

  javaRestTestImplementation('org.apache.arrow:arrow-vector:18.3.0')
  javaRestTestImplementation('org.apache.arrow:arrow-format:18.3.0')
  javaRestTestImplementation('org.apache.arrow:arrow-memory-core:18.3.0')
  javaRestTestImplementation('org.checkerframework:checker-qual:3.42.0')
  javaRestTestImplementation('com.google.flatbuffers:flatbuffers-java:23.5.26')
  javaRestTestImplementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
  javaRestTestImplementation("com.fasterxml.jackson.core:jackson-core:${versions.jackson}")
  javaRestTestImplementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
  javaRestTestImplementation("org.slf4j:slf4j-api:${versions.slf4j}")
  javaRestTestImplementation("org.slf4j:slf4j-nop:${versions.slf4j}")
  javaRestTestImplementation('org.apache.arrow:arrow-memory-unsafe:18.3.0')

  clusterPlugins project(':plugins:mapper-size')
  clusterPlugins project(':plugins:mapper-murmur3')
  clusterPlugins project(':x-pack:plugin:inference:qa:test-service-plugin')
}

restResources {
  restApi {
    include '_common', 'bulk', 'get', 'indices', 'esql', 'xpack', 'enrich', 'cluster', 'capabilities', 'index'
  }
  restTests {
    includeXpack 'esql'
  }
}

tasks.named('javaRestTest') {
  usesDefaultDistribution("to be triaged")
  maxParallelForks = 1
  jvmArgs('--add-opens=java.base/java.nio=ALL-UNNAMED')
}

tasks.named('yamlRestTest') {
  usesDefaultDistribution("to be triaged")
  maxParallelForks = 1
}
