plugins {
  // FIXME: This brings too many dependencies, refactor later
  id 'net.consensys.zkevm.kotlin-library-conventions'
  id 'com.github.johnrengelman.shadow' version '7.1.2'
}

archivesBaseName = 'linea-finalized-tag-updater'

repositories {
  maven {
    url "https://artifacts.consensys.net/public/linea-besu/maven/"
    content {
      includeGroupByRegex('org\\.hyperledger\\..*')
    }
  }
}

ext.groupsToIncludeInShadow = [
  "build.linea.*",
  "io.micrometer.*",
  "org.jetbrains.kotlin:kotlin-reflect.*",
  "org.jetbrains.kotlinx:kotlinx-datetime.*",
  "tech.pegasys.teku.internal:async",
  "com.michael-bull.kotlin-result:kotlin-result.*",
  "com.fasterxml.jackson.module:jackson-module-kotlin",
]

def canIncludeLib(String lib) {
  def allowed = groupsToIncludeInShadow.find { libAllowed ->
    lib.matches(libAllowed)
  } != null
  allowed
}


shadowJar {
  if ("${project.version}" != 'unspecified') {
    archiveClassifier.set('')
    archiveVersion.set("${project.version}")
  } else {
    archiveClassifier.set('SNAPSHOT')
  }

  dependencies {
    exclude {dependency ->
      def shallExclude = !canIncludeLib("${dependency.moduleGroup}:${dependency.moduleName}")
      shallExclude
    }
  }

  manifest {
    attributes(
        'Specification-Title': archiveBaseName,
        'Specification-Version': project.version,
        'Implementation-Title': archiveBaseName,
        'Implementation-Version': project.version,
        )
  }
}

dependencies {
  compileOnly project(":jvm-libs:linea:besu-libs")
  compileOnly 'info.picocli:picocli:4.7.6'
  compileOnly 'io.vertx:vertx-core'

  implementation project(":jvm-libs:generic:extensions:kotlin")
  implementation project(':jvm-libs:linea:core:long-running-service')
  implementation project(':jvm-libs:generic:extensions:futures')
  implementation project(':jvm-libs:linea:web3j-extensions')
  implementation project(':jvm-libs:linea:clients:linea-contract-clients')
  implementation ("org.web3j:core:${libs.versions.web3j.get()}") {
    exclude group: 'org.slf4j', module: 'slf4j-nop'
  }
  testImplementation 'info.picocli:picocli:4.7.6'
  testImplementation 'io.vertx:vertx-core'
}
