buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }

    dependencies {
        classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
    }
}

plugins {
    id 'com.github.johnrengelman.shadow' version '7.1.2'
    id 'com.adarshr.test-logger' version '3.2.0'
    id 'java'
    id 'jacoco'
    id 'checkstyle'
}

group 'services'
version '1.0-SNAPSHOT'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

compileJava {
    options.compilerArgs = ['-Xlint:unchecked']
}

sourceSets {
    main {
        java {
            srcDirs '../gencode/java'
            srcDirs '../common/src/main/java'
            srcDirs '../validator/src/main/java'
        }
    }
    test {
        java {
            srcDirs '../common/src/test/java'
        }
    }
}

test {
    finalizedBy jacocoTestReport
}

jacocoTestReport {
    dependsOn test
    reports {
        xml.required = true
        csv.required = false
        html.outputLocation = layout.BuildDirectory.dir('jacocoHtml')
    }
}

// TODO(future): jacocoTestCoverageVerification

checkstyle {
    ignoreFailures = false
    maxWarnings = 0
    configFile = file('../etc/checkstyle.xml')
}
checkstyleMain.source = 'src/main/java'

// TODO: Uncomment after java app is added in place of bin/bambi_service
//jar {
//    manifest {
//        attributes 'Main-Class': 'com.google.bos.iot.core.services.Application'
//    }
//}

shadowJar {
    mergeServiceFiles()
}

repositories {
    mavenCentral()
    mavenLocal()
    maven { url 'https://mvnrepository.com' }
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.5'
    implementation 'uk.org.lidalia:sysout-over-slf4j:1.0.2'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.4'
    implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.11.0'
    implementation group: 'com.github.java-json-tools', name: 'json-schema-validator', version: '2.2.14'
    implementation 'io.jsonwebtoken:jjwt:0.7.0'
    implementation 'javax.xml.bind:jaxb-api:2.3.1'
    implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0'
    implementation 'com.google.guava:guava:30.1.1-jre'
    implementation 'com.google.cloud:google-cloud-logging:2.3.2'
    implementation ('com.google.apis:google-api-services-cloudiot:v1-rev20210323-1.31.0') {
        exclude group: 'com.google.guava', module: 'guava-jdk5'
    }
    implementation 'commons-io:commons-io:2.5'
    implementation 'org.bouncycastle:bcpkix-jdk15on:1.64'

    implementation 'com.google.cloud:google-cloud-pubsub:1.66.0'
    implementation 'com.google.cloud:google-cloud-firestore:0.84.0-beta'
    implementation group: 'junit', name: 'junit', version: '4.13.2'
    implementation 'org.jetbrains:annotations:20.1.0'

    implementation 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
    implementation 'com.google.apis:google-api-services-sheets:v4-rev484-1.20.0'
    implementation 'ch.qos.logback:logback-classic:1.5.6'
    implementation ('com.google.apis:google-api-services-sourcerepo:v1-rev20220429-1.32.1') {
        exclude group: 'com.google.auth', module: 'google-auth-library-oauth2-http'
    }
    implementation 'org.eclipse.jgit:org.eclipse.jgit:6.9.0.202403050737-r'
    implementation('com.google.http-client:google-http-client-jackson2:1.43.3') {
        exclude group: 'com.google.auth', module: 'google-auth-library-oauth2-http'
    }
    implementation 'commons-validator:commons-validator:1.8.0'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
    testImplementation 'org.mockito:mockito-core:5.3.1'
    testImplementation 'org.mockito:mockito-junit-jupiter:5.6.0'
}
