import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE

/*
 * 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.legacy-java-rest-test'
apply plugin: 'elasticsearch.rest-resources'

dependencies {
  javaRestTestImplementation(testArtifact(project(xpackModule('snapshot-based-recoveries'))))
}

final File repoDir = file("$buildDir/testclusters/snapshot-recoveries-repo-license")

restResources {
  restApi {
    include 'indices', 'search', 'bulk', 'snapshot'
  }
}

tasks.withType(Test).configureEach {
  doFirst {
    delete(repoDir)
  }
  nonInputProperties.systemProperty 'tests.path.repo', repoDir
}

testClusters.matching { it.name == "javaRestTest" }.configureEach {
  testDistribution = 'DEFAULT'
  numberOfNodes = 3

  // This project tests that enterprise licensing is enforced,
  // therefore we use a basic license
  setting 'xpack.license.self_generated.type', 'basic'
  setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE
  setting 'xpack.security.enabled', 'false'
}
