/*
 * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
 * Public License v 1"; you may not use this file except in compliance with, at
 * your election, the "Elastic License 2.0", the "GNU Affero General Public
 * License v3.0 only", or the "Server Side Public License, v 1".
 */
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.yaml-rest-compat-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
  description = 'Module for ingest processors that do not require additional security permissions or have large dependencies and resources'
  classname ='org.elasticsearch.ingest.common.IngestCommonPlugin'
  extendedPlugins = ['lang-painless']
}

dependencies {
  compileOnly project(':modules:lang-painless:spi')
  api project(':libs:grok')
  api project(':libs:dissect')
  implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}"
  implementation "org.apache.httpcomponents:httpcore:${versions.httpcore}"
}

restResources {
  restApi {
    include '_common', 'ingest', 'cluster', 'indices', 'index', 'bulk', 'nodes', 'get', 'update', 'cat', 'mget', 'search', 'simulate', 'capabilities'
  }
}

tasks.withType(StandaloneRestIntegTestTask).configureEach {
  usesDefaultDistribution("to be triaged")
}

testClusters.configureEach {
  // Needed in order to test ingest pipeline templating:
  // (this is because the integTest node is not using default distribution, but only the minimal number of required modules)
  module ':modules:lang-mustache'
}

tasks.named("thirdPartyAudit").configure {
  ignoreMissingClasses(
    //commons-logging
    'org.apache.commons.codec.binary.Base64',
    'org.apache.commons.logging.Log',
    'org.apache.commons.logging.LogFactory',
  )
}

tasks.named("yamlRestCompatTestTransform").configure({ task ->
  task.skipTest("ingest/30_date_processor/Test week based date parsing", "week-date behaviour has changed")
  task.skipTest("ingest/120_grok/Test Grok Patterns Retrieval", "only counting the number of patterns, which may change")
})

configurations {
  basicRestSpecs {
    attributes {
      attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE)
    }
  }
}

artifacts {
  // This intentionally doesn't use the specify the `test` directory, because it creates a conflict with `/rest-api-spec/test/ingest/10_basic.yml` file.
  basicRestSpecs(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec"))
}
