/*
 * This file was generated by the Gradle 'init' task.
 */
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'java'
    id 'maven-publish'
    id 'application'
    id 'idea'

	id 'com.github.johnrengelman.shadow' version '5.0.0'
    id "com.github.sherter.google-java-format" version "0.8"
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
}

dependencies {
    def withoutX = { exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core:2.9.5' }

    compile 'com.jayway.jsonpath:json-path:2.4.0'
	compile 'org.freemarker:freemarker:2.3.28'
    compile 'org.apache.beam:beam-sdks-java-io-tika:2.13.0'
    compile 'org.apache.beam:beam-sdks-java-io-kafka:2.13.0'
    compile 'org.apache.beam:beam-sdks-java-core:2.13.0'
    compile 'org.apache.beam:beam-runners-spark:2.13.0'
    compile 'org.apache.beam:beam-runners-google-cloud-dataflow-java:2.13.0'
    compile 'org.apache.beam:beam-runners-flink_2.11:2.13.0'
    compile 'org.apache.beam:beam-sdks-java-extensions-sql:2.13.0'
    compile 'org.apache.beam:beam-sdks-java-io-mongodb:2.13.0'
    compile 'org.apache.beam:beam-sdks-java-io-jdbc:2.13.0'
    compile 'org.apache.derby:derby:10.14.2.0'
    compile 'org.apache.maven:maven-model:3.3.9'
    compile 'org.apache.poi:poi:3.17'
    compile 'org.apache.poi:poi-ooxml:3.17'
    compile 'org.apache.spark:spark-core_2.11:2.4.3'
    compile 'org.apache.spark:spark-streaming_2.11:2.4.3'
    compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.5'
    compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.5', withoutX
    compile 'com.github.haifengl:smile-core:1.5.2'
    compile 'com.github.wnameless:json-flattener:0.5.0'
    compile 'com.google.guava:guava:27.0.1-jre'
    compile 'com.google.cloud:google-cloud-storage:1.79.0'
    compile 'com.google.cloud:google-cloud-bigquery:1.79.0'
    compile 'com.thoughtworks.xstream:xstream:1.4.11'
    compile 'com.sparkjava:spark-core:2.9.1'
    compile 'commons-io:commons-io:2.6'
    compile 'commons-cli:commons-cli:1.4'
    compile 'ch.qos.logback:logback-classic:1.1.7'
    compile 'mysql:mysql-connector-java:8.0.13'
    compile 'joda-time:joda-time:2.4'
    compile 'org.jooq:jooq:3.11.9'
    compile 'org.postgresql:postgresql:42.2.5'
    compile 'org.slf4j:slf4j-api:1.7.25'
    compile 'org.quartz-scheduler:quartz:2.3.0'
    compile 'info.picocli:picocli:4.0.1'

    runtime 'org.apache.tika:tika-parsers:1.18'
    runtime 'org.slf4j:slf4j-jdk14:1.7.25'

    testCompile 'org.slf4j:slf4j-simple:1.7.22'
    testCompile 'org.hamcrest:hamcrest-core:1.3'
    testCompile 'org.hamcrest:hamcrest-library:1.3'
    testCompile 'org.mockito:mockito-core:1.9.5'
    testCompile 'junit:junit:4.12'
    testCompile 'com.github.stefanbirkner:system-rules:1.19.0'

    compileOnly 'org.projectlombok:lombok:1.16.2'
    compileOnly 'com.google.auto.value:auto-value:1.2'

    compile "com.google.auto.value:auto-value-annotations:1.6.2"
    annotationProcessor "com.google.auto.value:auto-value:1.6.2"
}



group = 'org.ananas'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}

mainClassName = 'org.ananas.runner.api.Main'

if (getSystemProperty('target', 'runner') == 'cli') {
    mainClassName = 'org.ananas.cli.Main'
}

shadowJar {
	zip64 true
	archiveName "${getSystemProperty('target', 'runner') == 'cli' ? project.cliJarName : project.runnerJarName}.jar"

    exclude 'META-INF/LICENSE'
    exclude 'LICENSE'
 
	mergeServiceFiles {
		include 'reference.conf'
	}

	manifest {
        attributes 'Implementation-Title': 'Ananas Analytics', 'Implementation-Version': "$project.version"
        attributes 'Main-Class': mainClassName
	}
}

googleJavaFormat {
  toolVersion = '1.7'
}

compileJava {
    dependsOn 'googleJavaFormat'
}

test {
    //we want display the following test events
    testLogging {
        // events "PASSED", "STARTED", "FAILED", "SKIPPED"
        showStandardStreams = true
    }

    systemProperties System.properties
    systemProperties 'java.security.policy': file("$projectDir/src/test/resources/test.policy").absolutePath
}

[run].each { runTask ->
    configure(runTask) {
        systemProperties System.properties

        if (project.hasProperty('args')) {
            args project.args.split(' ')
        }
    }
}
