/*
 * 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".
 */
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.yaml-rest-compat-test'
apply plugin: 'elasticsearch.internal-cluster-test'

esplugin {
  description = 'Adds "built in" aggregations to Elasticsearch.'
  classname ='org.elasticsearch.aggregations.AggregationsPlugin'
  extendedPlugins = ['lang-painless']
}

restResources {
  restApi {
    include 'capabilities', '_common', 'indices', 'cluster', 'index', 'search', 'nodes', 'bulk', 'scripts_painless_execute', 'put_script'
  }
  restTests {
    // Pulls in all aggregation tests from core AND the forwards v7's core for forwards compatibility
    includeCore 'search.aggregation'
  }
}

if (buildParams.snapshotBuild == false) {
  tasks.named("test").configure {
    systemProperty 'es.index_mode_feature_flag_registered', 'true'
  }
  tasks.named("internalClusterTest").configure {
    systemProperty 'es.index_mode_feature_flag_registered', 'true'
  }
}

artifacts {
  restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test"))
}

dependencies {
  compileOnly(project(':modules:lang-painless:spi'))
  clusterModules(project(':modules:lang-painless'))
}

tasks.named("yamlRestCompatTestTransform").configure({ task ->
  task.skipTest("aggregations/date_agg_per_day_of_week/Date aggregartion per day of week", "week-date behaviour has changed")
  task.skipTest("aggregations/time_series/Configure with no synthetic source", "temporary until backport")
  task.skipTest("aggregations/percentiles_hdr_metric/Negative values test", "returned exception has changed")
  task.skipTest("aggregations/moving_fn/linearWeightedAvg", "math was wrong in previous versions")
})
