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

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

group = 'build.linea.staterecover'

dependencies {
  implementation(project(':jvm-libs:generic:extensions:futures'))
  implementation(project(':jvm-libs:generic:extensions:kotlin'))
  implementation(project(':jvm-libs:generic:extensions:tuweni'))
  implementation(project(':jvm-libs:generic:http-rest'))
  implementation(project(':jvm-libs:generic:json-rpc'))
  implementation(project(':jvm-libs:generic:vertx-helper'))
  implementation(project(':jvm-libs:linea:clients:linea-state-manager'))
  implementation(project(':jvm-libs:linea:core:domain-models'))
  implementation(project(':jvm-libs:linea:core:long-running-service'))
  implementation(project(':besu-plugins:state-recovery:appcore:clients-interfaces'))
  implementation("io.vertx:vertx-web-client:${libs.versions.vertx}")

  testImplementation "org.wiremock:wiremock:${libs.versions.wiremock.get()}"
  testImplementation "org.slf4j:slf4j-api:${libs.versions.slf4j.get()}"
  testImplementation project(":jvm-libs:generic:logging")
  testImplementation "io.github.hakky54:logcaptor:${libs.versions.logcaptor.get()}"
}

sourceSets {
  integrationTest {
    kotlin {
      compileClasspath += sourceSets.main.output
      runtimeClasspath += sourceSets.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 false
  }
}
