import tasks.ReportGenerateTask

plugins {
	id 'java-library'
	id 'org.jetbrains.kotlin.jvm' version '2.0.20'
	id 'com.google.devtools.ksp' version '2.0.20-1.0.25'
	id 'maven-publish'
}

group = 'org.koitharu'
version = '1.0'

test {
	useJUnitPlatform()
}

ksp {
	arg("summaryOutputDir", "${projectDir}/.github")
}

compileKotlin {
	kotlinOptions {
		freeCompilerArgs += [
			'-opt-in=kotlin.RequiresOptIn',
			'-opt-in=kotlin.contracts.ExperimentalContracts',
			'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
			'-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi',
		]
	}
}

compileTestKotlin {
	kotlinOptions {
		freeCompilerArgs += [
			'-opt-in=kotlin.RequiresOptIn',
			'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
			'-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi',
		]
	}
}

kotlin {
	jvmToolchain(8)
	explicitApi = 'warning'
	sourceSets {
		main.kotlin.srcDirs += 'build/generated/ksp/main/kotlin'
	}
}

afterEvaluate {
	publishing {
		publications {
			mavenJava(MavenPublication) {
				from components.java
			}
		}
	}
}

dependencies {
	implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0'
	implementation 'com.squareup.okhttp3:okhttp:4.12.0'
	implementation 'com.squareup.okio:okio:3.9.0'
	api 'org.jsoup:jsoup:1.18.1'
	implementation 'org.json:json:20240303'
	implementation 'androidx.collection:collection:1.4.2'

	ksp project(':kotatsu-parsers-ksp')

	testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
	testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.1'
	testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.1'
	testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
	testImplementation 'io.webfolder:quickjs:1.1.0'
}

tasks.register('generateTestsReport', ReportGenerateTask)
