plugins {
  id 'net.consensys.zkevm.kotlin-common-minimal-conventions'
  id 'net.consensys.zkevm.linea-native-libs-helper'
}

description = 'Java JNA wrapper for Linea Blob Shnarf Calculator implemented in GO Lang'

dependencies {
  compileOnly "net.java.dev.jna:jna:${libs.versions.jna.get()}"

  testImplementation "net.java.dev.jna:jna:${libs.versions.jna.get()}"
  testImplementation project(":jvm-libs:generic:extensions:kotlin")
}

jar {
  dependsOn configurations.runtimeClasspath
}


test {
  // we cannot have more 1 compressor per JVM, hence we disable parallel execution
  // because multiple threads would cause issues with the native library
  systemProperties["junit.jupiter.execution.parallel.enabled"] = false
  maxParallelForks = 1
}

def libsZipDownloadOutputDir = project.parent.layout.buildDirectory.asFile.get().absolutePath

task downloadNativeLibs {
  doLast {
    fetchLibFromZip("https://github.com/Consensys/linea-monorepo/releases/download/blob-libs-v1.2.0/linea-blob-libs-v1.2.0.zip", "shnarf_calculator", libsZipDownloadOutputDir)
  }
}

compileKotlin {
  dependsOn tasks.downloadNativeLibs
}
