displayName = "Spock Framework - Specs for Core Module"

description = "Spock specifications for the Core Module. Yes, we eat our own dog food."

apply plugin: "spock-base"

configurations {
  spockReport
  junit
}

// for "com.github.cglib:cglib.cglib-nodep:e10bc3dda2"
repositories {
  maven {
    url "https://jitpack.io"
  }
}

dependencies {
  testCompile project(":spock-core")

  testRuntime libs.asm
  testRuntime javaVersion >= 1.8 ? "com.github.cglib:cglib.cglib-nodep:e10bc3dda2" : libs.cglib
  testRuntime libs.objenesis
  testRuntime libs.h2database

  spockReport project(":spock-report")

  junit libs.junit
}

// necessary to make @NotYetImplemented transform work (transform that ships 
// with Groovy and statically references third-party class junit.framwork.AssertionFailedError)
tasks.withType(GroovyCompile) {
	groovyClasspath += configurations.junit
}

ext.spockLogFileDir = file("$buildDir/spock/logFiles")
ext.spockLogFileName = "spock-log"

test {
  finalizedBy "spockReport"
  reports.junitXml.enabled = true
  reports.html.enabled = false

  testLogging.exceptionFormat = "full"
  testLogging.showExceptions = true
  maxParallelForks = 1

  systemProperty "spock.logFileDir", spockLogFileDir
  systemProperty "spock.logFileName", spockLogFileName
  //systemProperty "spock.reportServerAddress", "127.0.0.1"

  doFirst {
    delete spockLogFileDir
  }
}

task spockReport(type: org.spockframework.gradle.GenerateSpockReport) {
  reportName = "spock-specs"
  reportFileName = "spock-specs.html"
  debug = true
  local = true
  liveLogFiles = (1..10).collect { file("$spockLogFileDir/$spockLogFileName-$it") }
  spockReportClasspath = configurations.spockReport
  outputDirectory = file("$buildDir/reports/spock/$variant")
}

task groovyConsole(type: JavaExec) {
  main = "groovy.ui.Console"
  classpath = sourceSets.test.runtimeClasspath
}
