/**
 * This Gradle file sets up common build settings for Scala 2.10.x projects
 */

ext {
    scala211Version = '2.11.8'
}

// Language support
apply plugin: 'java'
apply plugin: 'scala'


/**
 * Include basic package dependencies that ALL Airbnb Scala projects will need.
 * This should include no team or project specific code. That will only bloat other
 * Scala projects.
 *
 * Additionally, don't include domain specific libraries such as Spark.
 */
dependencies {
    compile libraries.scala_library_211
    compile libraries.scala_logging_slf4j_211
    compile libraries.org_scala_lang_modules_scala_java8_compat_2_11
}

/**
 * Set standard Scala compilation options
 */
def getScalaCompileAdditionalParameters = {
    def compileOptions = [
            // Emit warning and location for usages of features that should be imported explicitly.
            '-feature',
            // Output messages about what the compiler is doing.
            '-verbose',
            // Enable recommended additional warnings.
            '-Xlint',
    ]
    if (project.hasProperty('SkipWarning')) {
        compileOptions << '-nowarn'
    }
    compileOptions
}
tasks.withType(ScalaCompile) {
    // Target Java 1.8 level compatibility
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'

    scalaCompileOptions.with {
        deprecation = true
        unchecked = true
        optimize = true
        debugLevel = 'vars'
        additionalParameters = getScalaCompileAdditionalParameters()
    }
}


/**
 * Task: `repl`
 *
 * Will initiate a command-line Scala console that you can use
 * to interact live with your project's code.
 *
 * Run with `gradlew repl --console plain --no-daemon`
 */
task repl(type: JavaExec) {
    dependencies {
        compile group: 'org.scala-lang', name: 'scala-compiler', version: scala211Version
    }
    main = 'scala.tools.nsc.MainGenericRunner'
    classpath = sourceSets.main.runtimeClasspath
    standardInput System.in
    args '-usejavacp'
}
