import com.github.jk1.license.filter.LicenseBundleNormalizer

buildscript {
  ext {
    distributionIdentifier = "linea-sequencer"
    releaseVersion = "${libs.versions.arithmetization.get()}-SNAPSHOT"
    besuVersion = "${libs.versions.besu.get()}"
    besuRepo = "https://artifacts.consensys.net/public/linea-besu/maven/"
  }
}

plugins {
  alias(libs.plugins.besuPluginLibrary)
  alias(libs.plugins.besuPluginDistribution)
  alias(libs.plugins.dependencyLicenseReport)
}

licenseReport {
  // This is for the allowed-licenses-file in checkLicense Task
  // Accepts File, URL or String path to local or remote file
  allowedLicensesFile = project.file("gradle/allowed-licenses.json")

  excludes = []

  // If set to true, then all boms will be excluded from the report
  excludeBoms = true

  filters = [
    new LicenseBundleNormalizer(bundlePath: project.file("gradle/license-normalizer-bundle.json"))
  ]
}

// Make the parent project's spotlessCheck depend on all subproject spotlessCheck tasks
afterEvaluate {
  if (tasks.findByName('spotlessCheck')) {
    spotlessCheck.dependsOn subprojects.collect { subproject ->
      subproject.tasks.matching { task -> task.name == 'spotlessCheck' }
    }
  }
  if (tasks.findByName('spotlessApply')) {
    spotlessApply.dependsOn subprojects.collect { subproject ->
      subproject.tasks.matching { task -> task.name == 'spotlessApply' }
    }
  }
}

build {
  dependsOn checkLicense
}

jar {
  enabled = false
}
