apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.publish'
apply plugin: 'com.gradleup.shadow'

description = 'JDBC driver for Elasticsearch'

base {
  archivesName = "x-pack-sql-jdbc"
}

tasks.named('forbiddenApisMain').configure {
  // does not depend on core, so only jdk and http signatures should be checked
  replaceSignatureFiles 'jdk-signatures'
}

dependencies {
  api project(':x-pack:plugin:sql:sql-client')
  testImplementation project(":test:framework")
  testImplementation(testArtifact(project(xpackModule('core'))))
  testImplementation project(':modules:rest-root')
}

java {
  targetCompatibility = JavaVersion.VERSION_1_8
  sourceCompatibility = JavaVersion.VERSION_1_8
}

tasks.named("compileTestJava").configure {
  targetCompatibility = buildParams.getMinimumRuntimeVersion()
  sourceCompatibility = buildParams.getMinimumRuntimeVersion()
}

tasks.named("test").configure {
  // reset the unit test classpath as using the shadow jar won't work due to relocated packages
  classpath = sourceSets.test.runtimeClasspath
}

tasks.named("shadowJar").configure {
  relocate 'com.fasterxml', 'shadow.fasterxml'
  relocate('org.elasticsearch', 'shadow.org.elasticsearch') {
    // Don't relocate the JDBC driver classes themselves as that's (mostly) public API
    exclude 'org.elasticsearch.xpack.sql.jdbc.*'
  }
}

