/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * The OpenSearch Contributors require contributions made to
 * this file be licensed under the Apache-2.0 license or a
 * compatible open source license.
 */

subprojects {
  /*
   * All subprojects are java projects using OpenSearch's standard build
   * tools.
   */
  apply plugin: 'opensearch.build'

  /*
   * Subprojects may depend on the "core" lib but may not depend on any
   * other libs. This keeps our dependencies simpler.
   */
  project.afterEvaluate {
    configurations.all { Configuration conf ->
      dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
        Project depProject = dep.dependencyProject
        if (depProject != null
          && false == depProject.path.equals(':libs:opensearch-core')
          && depProject.path.startsWith(':libs')) {
          throw new InvalidUserDataException("projects in :libs " +
            "may not depend on other projects libs except " +
            ":libs:opensearch-core but " +
            "${project.path} depends on ${depProject.path}")
        }
      }
    }
  }
}