/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

apply plugin: 'java-library'

description = 'SQL Module'

dependencies {
  implementation platform(project(':platform'))
  permitUnusedDeclared platform(project(":platform"))
  implementation project(':solr:core')
  implementation project(':solr:solrj')
  implementation project(':solr:solrj-streaming')
  implementation project(':solr:solrj-zookeeper')

  implementation libs.slf4j.api
  implementation libs.google.guava

  // SQL Parser via Calcite
  implementation(libs.apache.calcite.core, {
    exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-yaml'
    exclude group: 'com.google.uzaygezen', module: 'uzaygezen-core'
    exclude group: 'com.yahoo.datasketches', module: 'sketches-core'
    exclude group: 'org.apache.commons', module: 'commons-dbcp2'
    exclude group: 'net.minidev', module: 'json-smart'
    exclude group: 'net.hydromatic', module: 'aggdesigner-algorithm'
  })
  compileOnly libs.immutables.valueannotations // needed due to Calcite requiring this CALCITE-4787
  // sub-deps of calcite-core that we reference directly
  implementation libs.apache.calcite.linq4j
  implementation libs.apache.calcite.avatica.core
  permitUnusedDeclared libs.apache.calcite.avatica.core

  testImplementation project(':solr:test-framework')
  testImplementation libs.apache.lucene.testframework
  testImplementation libs.junit.junit

  testRuntimeOnly project(':solr:modules:analysis-extras')
}


// Copy all the test resource files from core to the build/resources/test directory
// of the SQL module so we can avoid duplication of the test resource files like
// schemas and SolrConfigs. This can be improved later by making the test classes
// load the resources from core directories directly.
tasks.register('copySolrCoreTestResources', Copy) {
  from(project(':solr:core').sourceSets.test.resources.srcDirs) {
    exclude '**/*.java'
  }
  into sourceSets.test.output.resourcesDir
}

tasks.named('processTestResources').configure {
  dependsOn copySolrCoreTestResources
}
