import java.time.LocalTime

/*
 * Copyright Consensys Software Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

plugins {
  alias(libs.plugins.web3j)
  alias(libs.plugins.web3jSolidity)
  alias(libs.plugins.lombok)
  alias(libs.plugins.gradleVersions)
  alias(libs.plugins.dependencyManagement)
  alias(libs.plugins.download)
}

def lineaSequencerProject = project(lineaSequencerProjectPath)
apply from: lineaSequencerProject.file("gradle/java.gradle")
apply from: lineaSequencerProject.file("gradle/dependency-management.gradle")
apply from: lineaSequencerProject.file('gradle/common-dependencies.gradle')
apply from: lineaSequencerProject.file("gradle/lint.gradle")

web3j {
  generatedPackageName = 'linea.plugin.acc.test.tests.web3j.generated'
}

solidity {
  resolvePackages = false
  optimizeRuns = 1
  // TODO: remove the forced version, when DEV network is upgraded to support latest forks
  version '0.8.19'
}

processTestResources.dependsOn("${lineaSequencerProjectPath}:acceptance-tests:generateTestContractWrappers")

tasks.register('acceptanceTests', Test) {
  description = 'Runs acceptance tests.'

  inputs.property("integration.date", LocalTime.now()) // so it runs on every invocation

  useJUnitPlatform {
    includeTags("AcceptanceTest")
  }

  maxParallelForks Runtime.runtime.availableProcessors()
  systemProperties["junit.jupiter.execution.parallel.enabled"] = false
}

dependencies {
  annotationProcessor 'org.apache.logging.log4j:log4j-core'

  implementation 'org.apache.logging.log4j:log4j-core'

  testImplementation project("${lineaSequencerProjectPath}:sequencer")

  testImplementation "${besuArtifactGroup}:besu-datatypes"
  testImplementation "${besuArtifactGroup}.internal:clique"
  testImplementation "${besuArtifactGroup}.internal:api"
  testImplementation "${besuArtifactGroup}.internal:core"
  testImplementation "${besuArtifactGroup}.internal:dsl"
  testImplementation "${besuArtifactGroup}.internal:eth"
  testImplementation "${besuArtifactGroup}.internal:metrics-core"
  testImplementation "${besuArtifactGroup}.internal:services"
  testImplementation group: "${besuArtifactGroup}.internal", name: "core", classifier: "test-support"

  testImplementation 'net.consensys.linea.zktracer:arithmetization'

  testImplementation 'org.awaitility:awaitility'
}

// Do not run acceptance tests with ./gradlew test, only with ./gradlew acceptanceTests
test.enabled = false

jar {
  enabled = false
}
