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

dependencies {
  compile project(":gobblin-api")
  compile project(":gobblin-core")
  compile project(":gobblin-metrics-libs:gobblin-metrics")
  compile project(":gobblin-metastore")
  compile project(":gobblin-runtime")
  compile project(":gobblin-utility")
  compile project(path: ':gobblin-rest-service:gobblin-rest-api', configuration: 'restClient')
  compile project(":gobblin-rest-service:gobblin-rest-server")

  compile externalDependency.avro
  compile externalDependency.commonsConfiguration
  compile externalDependency.quartz
  compile externalDependency.guava
  compile externalDependency.commonsLang
  compile externalDependency.slf4j
  compile externalDependency.commonsCli
  compile externalDependency.gson
  compile externalDependency.hiveCommon
  compile externalDependency.metricsCore
  compile externalDependency.metricsJvm
  compile externalDependency.commonsIo
  compile externalDependency.commonsEmail
  compile externalDependency.pegasus.data
  compile externalDependency.typesafeConfig
  compile externalDependency.zkClient
  compile externalDependency.hadoopClientCommon
  compile externalDependency.hadoopCommon
  compile externalDependency.avroMapredH2
  compile externalDependency.findBugsAnnotations
  compile (externalDependency.helix) {
    exclude group: 'io.dropwizard.metrics', module: 'metrics-core'
  }
  compile externalDependency.jacksonMapperAsl

  runtimeOnly project(":gobblin-modules:gobblin-service-kafka")

  testCompile project(":gobblin-example")

  testCompile externalDependency.testng
  testCompile externalDependency.curatorFramework
  testCompile externalDependency.curatorTest
  testCompile externalDependency.assertj
  testCompile externalDependency.mockito
}

task testJar(type: Jar, dependsOn: testClasses) {
  baseName = "${project.archivesBaseName}-test"
  from sourceSets.test.output
}

configurations {
  tests
}

artifacts {
  tests testJar
  archives testJar
}

configurations {
  compile {
    transitive = false
  }

  testRuntime {
    resolutionStrategy {
      force 'com.google.inject:guice:3.0'
    }
  }
}
// Generates a maven test artifact (gobblin-cluster-test)
project.publishing.publications {
  testsPub(MavenPublication) {
    artifactId "${project.archivesBaseName}-test"
    artifacts = [testJar]
    pom pomAttributes
    pom.withXml addRuntimeDependenciesToPom
  }
}

artifactory {
  publish {
    defaults {
      publications('mavenJava', 'testsPub')
    }
  }
}

test {
  workingDir rootProject.rootDir
  maxParallelForks = 1
}

install {
  repositories {
    mavenInstaller {
      addFilter(testJar.baseName) { artifact, file ->
        artifact.name == testJar.baseName
      }.project(rootProject.pomAttributes).artifactId = testJar.baseName
      addFilter('') { artifact, file ->
        artifact.name == jar.baseName
      }
    }
  }
}
if (rootProject.ext.publishToMaven || rootProject.ext.publishToNexus) {
  uploadArchives {
    repositories {
      mavenDeployer {
        addFilter(testJar.baseName) { artifact, file ->
          artifact.name == testJar.baseName
        }.project(rootProject.pomAttributes).artifactId = testJar.baseName
        addFilter('') { artifact, file ->
          artifact.name == jar.baseName
        }
      }
    }
  }
}

ext.classification="library"
