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

buildscript {
  ext {
    distributionIdentifier = "linea-sequencer"
    releaseVersion = "${libs.versions.arithmetization.get()}-SNAPSHOT"
    distributionBaseUrl = "https://github.com/Consensys/linea-besu-upstream/releases/download/"
    besuIdentifier = "besu-${libs.versions.besu.get()}"
    besuFilename = "${besuIdentifier}.tar.gz"
    besuUrl = "${distributionBaseUrl}${libs.versions.besu.get()}/${besuFilename}"
    besuPluginsIdentifier = "${distributionIdentifier}-${version}"
    besuPluginDir = File.createTempDir("plugins")
  }
}

plugins {
  id 'java-library'
  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
}
