plugins {
  id 'org.jetbrains.kotlin.multiplatform'
  id 'maven-publish'
}
repositories {
  mavenCentral()
}
ext {
  maven_name = 'selfie-lib'
  maven_desc = 'Core logic and parsing for Selfie'
}
apply from: 干.file('base/changelog.gradle')
apply from: rootProject.file('gradle/spotless.gradle')
kotlin {
  jvm {
    testRuns["test"].executionTask.configure {
      useJUnitPlatform()
    }
    compilations.main {
      compilerOptions.configure((org.gradle.api.Action) {
        it.setFreeCompilerArgs(['-Xjvm-default=all'])
      })
    }
  }
  js {
    nodejs()
  }
  sourceSets {
    commonMain {
      dependencies {
        compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-json:$ver_KOTLIN_SERIALIZATION")
      }
    }
    jsMain {
      dependencies {
        api("org.jetbrains.kotlinx:kotlinx-serialization-json:$ver_KOTLIN_SERIALIZATION")
      }
    }
    commonTest {
      dependencies {
        implementation kotlin('test')
        implementation("io.kotest:kotest-assertions-core:$ver_KOTEST")
        implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$ver_KOTLIN_SERIALIZATION")
      }
    }
  }
  targets.configureEach {
    compilations.configureEach {
      compilerOptions.configure((Action) { it.freeCompilerArgs.add("-Xexpect-actual-classes") })
    }
  }
}

// the normal `test` task doesn't work for multiplatform projects
tasks.register('test') {
  dependsOn('jvmTest')
}

// it all needs to get published and formatted
apply from: 干.file('base/maven.gradle')
apply from: 干.file('base/sonatype.gradle')
apply from: rootProject.file('gradle/jvm-target.gradle')
