import java.util.Properties
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
	kotlin("multiplatform") version "2.0.20"
	`maven-publish`
}



val versions = Properties()
versions.load(rootDir.resolve("../versions.properties").inputStream())

val targetKotlinVersion = versions.getProperty("kotlin")

group = "ru.landgrafhomyak.kotlin"
version = "v${versions.getProperty("this")}k${targetKotlinVersion}"

repositories {
	mavenCentral()
}


kotlin {
	explicitApi()
	jvmToolchain(8)

	targets.configureEach {
		this.compilations.configureEach {
			compileTaskProvider.configure {
				this.compilerOptions {
					this.languageVersion.set(KotlinVersion.KOTLIN_1_8)
					this.apiVersion.set(KotlinVersion.KOTLIN_1_8)
				}
			}
		}
	}

	jvm()


	sourceSets {
		jvmMain {
			dependencies {
				compileOnly("dev.gradleplugins:gradle-api:${versions.getProperty("gradle")}")
				compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:${targetKotlinVersion}")
			}
		}
	}
}

publishing {
	repositories {
		maven {
			name = "XomrkMaven"
			url = uri("https://git.landgrafhomyak.ru/api/packages/xomrk/maven")

			credentials(HttpHeaderCredentials::class) {
				name = "Authorization"
				value = "token ${System.getenv("XOMRK_GITEA_MAVEN_REPO_DEPLOY_TOKEN")}"
			}

			authentication {
				create<HttpHeaderAuthentication>("header")
			}
		}
	}
	publications {
		withType<MavenPublication> {
			artifactId = project.name
		}
	}
}