/*
 * Copyright Thoughtworks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
  id 'groovy'
}

dependencies {
  api project(':config:config-api')
  api project(':spark:spark-base')
  api project(':server')
  implementation(project.deps.apacheHttpComponents) {
    exclude(module: 'commons-codec')
  }
  if (project.deps.apacheHttpComponents) {
    runtimeOnly project.deps.slf4jJcl // Allow commons-logging replacement
  }

  api project.deps.gson
  api project.deps.springContext
  implementation project.deps.commonsCodec
  implementation project.deps.springWeb

  testImplementation localGroovy()
  testImplementation project.deps.junit5Api
  testRuntimeOnly project.deps.junit5Engine
  testRuntimeOnly project.deps.junit5PlatformLauncher

  testFixturesApi localGroovy()
  testFixturesApi(testFixtures(project(':spark:spark-base')))
  testFixturesApi(testFixtures(project(':config:config-api')))
  testFixturesApi(testFixtures(project(':common')))
  testFixturesApi(testFixtures(project(':domain')))

  testFixturesApi project.deps.jsonUnit
  testFixturesApi project.deps.mockitoCore
  testFixturesApi project.deps.mockitoJunit5
  testFixturesApi project.deps.springTest
}

dependencyAnalysis {
  issues {
    // We ignore these for now because api-base is essentially used to propagate dependencies to the dozemns
    // of individual API projects where it doesn't add value to declare them directly.
    onIncorrectConfiguration {
      exclude(project.deps.mockitoJunit5 as String)
    }
    onUnusedDependencies {
      exclude(dependencies.project(path: ':spark:spark-base', configuration: 'testFixtures') as ProjectDependency)
      exclude(dependencies.project(path: ':common', configuration: 'testFixtures') as ProjectDependency)
      exclude(dependencies.project(path: ':domain', configuration: 'testFixtures') as ProjectDependency)
    }
  }
}