import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
  id 'net.consensys.zkevm.kotlin-library-conventions'
}

dependencies {
  implementation(project(":coordinator:core"))
  implementation(project(":coordinator:clients:smart-contract-client"))
  implementation(project(":jvm-libs:linea:web3j-extensions"))
  implementation(testFixtures(project(":jvm-libs:linea:web3j-extensions")))
  implementation(project(":coordinator:ethereum:common"))
  implementation(project(":jvm-libs:linea:testing:file-system"))
  implementation("org.web3j:core:${libs.versions.web3j.get()}") {
    exclude group: 'org.slf4j', module: 'slf4j-nop'
  }
  implementation "com.sksamuel.hoplite:hoplite-core:${libs.versions.hoplite.get()}"
  implementation "com.sksamuel.hoplite:hoplite-toml:${libs.versions.hoplite.get()}"
  implementation "com.fasterxml.jackson.core:jackson-annotations:${libs.versions.jackson.get()}"
  implementation "com.fasterxml.jackson.core:jackson-databind:${libs.versions.jackson.get()}"
  implementation "com.fasterxml.jackson.module:jackson-module-kotlin:${libs.versions.jackson.get()}"
  implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${libs.versions.jackson.get()}"
  implementation "org.awaitility:awaitility:4.2.0"
}

sourceSets {
  integrationTest {
    kotlin {
      compileClasspath += main.output
      runtimeClasspath += main.output
    }
    compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath + sourceSets.test.compileClasspath
    runtimeClasspath += sourceSets.main.output + sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
  }
}

task integrationTest(type: Test) { test ->
  description = "Runs integration tests."
  group = "verification"
  useJUnitPlatform()

  classpath = sourceSets.integrationTest.runtimeClasspath
  testClassesDirs = sourceSets.integrationTest.output.classesDirs

  dependsOn(":localStackComposeUp")
  testLogging {
    events TestLogEvent.FAILED,
        TestLogEvent.SKIPPED,
        TestLogEvent.STANDARD_ERROR,
        TestLogEvent.STARTED,
        TestLogEvent.PASSED
    exceptionFormat TestExceptionFormat.FULL
    showCauses true
    showExceptions true
    showStackTraces true
    // set showStandardStreams if you need to see test logs
    showStandardStreams true
  }
}
