plugins {
  id 'org.jetbrains.kotlin.multiplatform'
  id 'com.diffplug.spotless'
}
repositories {
  mavenCentral()
}
spotless {
  enforceCheck = false
  kotlin {
    target 'src/**/*.kt'
    toggleOffOn()
    licenseHeader ''
    ktfmt()
    replaceRegex("test one-liner", "@Test\n(\\s*)fun ", "@Test fun ")
    replaceRegex("test harness comments", "\n(\\s)*//", "\n//")
  }
}

kotlin {
  jvm {
  }
  //  js { TODO: need to implement selfie-lib for js first
  //    nodejs()
  //  }
  sourceSets {
    commonTest {
      dependencies {
        implementation(project(":selfie-lib"))
        implementation(project(":selfie-runner-kotest"))
        implementation("io.kotest:kotest-framework-engine:$ver_KOTEST")
        implementation("io.kotest:kotest-assertions-core:$ver_KOTEST")
        implementation(kotlin('test'))
      }
    }
    jvmTest {
      dependencies {
        implementation "io.kotest:kotest-runner-junit5:$ver_KOTEST"
      }
    }
  }
}
tasks.named('jvmTest').configure {
  useJUnitPlatform()
  enabled = findProperty("underTest") == "true"
  testLogging.showStandardStreams = true
  // the snapshots are both output and input, for this harness best if the test just always runs
  outputs.upToDateWhen { false }
  // defaults to 'write'
  String SELFIE = findProperty('selfie')
  if (SELFIE != null) {
    environment['SELFIE'] = SELFIE
  }
}