/*
 * 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.build'

base {
  archivesName = "x-content-impl"
}

String jacksonVersion = "2.17.2"

dependencies {
  compileOnly project(':libs:core')
  compileOnly project(':libs:x-content')
  implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
  implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${jacksonVersion}"
  implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"
  implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jacksonVersion}"
  implementation "org.yaml:snakeyaml:${versions.snakeyaml}"

  testImplementation(project(":test:framework")) {
    exclude group: 'org.elasticsearch', module: 'x-content'
  }
}

tasks.named('forbiddenApisMain').configure {
  // x-content does not depend on server
  // TODO: Need to decide how we want to handle for forbidden signatures with the changes to core
  replaceSignatureFiles 'jdk-signatures'
}

tasks.named("dependencyLicenses").configure {
  mapping from: /jackson-.*/, to: 'jackson'
}

// workaround for (/com/fasterxml/jackson/core/JsonFactory.class): warning: Cannot find annotation method
// 'value()' in type 'ServiceProvider': class file for aQute.bnd.annotation.spi.ServiceProvider not found
tasks.withType(JavaCompile).configureEach {
  options.compilerArgs.add("-Xlint:-classfile")
}

// not published, so no need for javadoc
tasks.named("javadoc").configure { enabled = false }

tasks.named("thirdPartyAudit").configure {
  ignoreMissingClasses(
    // from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
    'com.fasterxml.jackson.databind.ObjectMapper',
    'com.fasterxml.jackson.databind.cfg.MapperBuilder'
  )
}

tasks.named("licenseHeaders").configure {
  approvedLicenses = ['Apache', 'AGLP+SSPL+Elastic License', 'Generated', 'Vendored']
}
