plugins {
	id 'com.android.application'
	id 'kotlin-android'
	id 'com.google.devtools.ksp'
	id 'kotlin-parcelize'
	id 'dagger.hilt.android.plugin'
	id 'androidx.room'
	id 'org.jetbrains.kotlin.plugin.serialization'
	// enable if needed
	// id 'dev.reformator.stacktracedecoroutinator'
}

android {
	compileSdk = 36
	buildToolsVersion = '35.0.0'
	namespace = 'org.dokiteam.doki'

	defaultConfig {
		applicationId 'org.dokiteam.doki'
		minSdk = 21
		targetSdk = 36
		versionCode = 1011
		versionName = '1.2.7'
		generatedDensities = []
		testInstrumentationRunner 'org.dokiteam.doki.HiltTestRunner'
		ksp {
			arg('room.generateKotlin', 'true')
		}
		androidResources {
			generateLocaleConfig false
		}
		def localProperties = new Properties()
		def localPropertiesFile = rootProject.file('local.properties')
		if (localPropertiesFile.exists()) {
			localProperties.load(new FileInputStream(localPropertiesFile))
		}
		resValue 'string', 'tg_backup_bot_token', localProperties.getProperty('tg_backup_bot_token', '')
	}
	buildTypes {
		debug {
			applicationIdSuffix = '.debug'
		}
		release {
			minifyEnabled true
			shrinkResources true
			proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
		}
	}
	buildFeatures {
		viewBinding true
		buildConfig true
	}
	packagingOptions {
		resources {
			excludes += [
				'META-INF/README.md',
				'META-INF/NOTICE.md'
			]
		}
	}
	sourceSets {
		androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
		main.java.srcDirs += 'src/main/kotlin/'
	}
	compileOptions {
		coreLibraryDesugaringEnabled true
		sourceCompatibility JavaVersion.VERSION_11
		targetCompatibility JavaVersion.VERSION_11
	}
	kotlinOptions {
		jvmTarget = JavaVersion.VERSION_11.toString()
		freeCompilerArgs += [
			'-opt-in=kotlin.ExperimentalStdlibApi',
			'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
			'-opt-in=kotlinx.coroutines.ExperimentalForInheritanceCoroutinesApi',
			'-opt-in=kotlinx.coroutines.InternalForInheritanceCoroutinesApi',
			'-opt-in=kotlinx.coroutines.FlowPreview',
			'-opt-in=kotlin.contracts.ExperimentalContracts',
			'-opt-in=coil3.annotation.ExperimentalCoilApi',
			'-opt-in=coil3.annotation.InternalCoilApi',
			'-opt-in=kotlinx.serialization.ExperimentalSerializationApi',
			'-Xjspecify-annotations=strict',
			'-Xtype-enhancement-improvements-strict-mode'
		]
	}
	room {
		schemaDirectory "$projectDir/schemas"
	}
	lint {
		abortOnError true
		disable 'MissingTranslation', 'PrivateResource', 'SetJavaScriptEnabled', 'SimpleDateFormat'
	}
	testOptions {
		unitTests.includeAndroidResources true
		unitTests.returnDefaultValues false
		kotlinOptions {
			freeCompilerArgs += ['-opt-in=org.dokiteam.doki.parsers.InternalParsersApi']
		}
	}
}
dependencies {
	implementation(libs.doki.exts) {
		exclude group: 'org.json', module: 'json'
	}

	coreLibraryDesugaring libs.desugar.jdk.libs
	implementation libs.kotlin.stdlib
	implementation libs.kotlinx.coroutines.android
	implementation libs.kotlinx.coroutines.guava

	implementation libs.androidx.appcompat
	implementation libs.androidx.core
	implementation libs.androidx.activity
	implementation libs.androidx.fragment
	implementation libs.androidx.transition
	implementation libs.androidx.collection
	implementation libs.lifecycle.viewmodel
	implementation libs.lifecycle.service
	implementation libs.lifecycle.process
	implementation libs.androidx.constraintlayout
	implementation libs.androidx.documentfile
	implementation libs.androidx.swiperefreshlayout
	implementation libs.androidx.recyclerview
	implementation libs.androidx.viewpager2
	implementation libs.androidx.preference
	implementation libs.androidx.biometric
	implementation libs.material
	implementation libs.androidx.lifecycle.common.java8
	implementation libs.androidx.webkit

	implementation libs.androidx.work.runtime
	implementation libs.guava

	implementation libs.androidx.room.runtime
	implementation libs.androidx.room.ktx
	ksp libs.androidx.room.compiler

	implementation libs.okhttp
	implementation libs.okhttp.tls
	implementation libs.okhttp.dnsoverhttps
	implementation libs.okio
	implementation libs.kotlinx.serialization.json

	implementation libs.adapterdelegates
	implementation libs.adapterdelegates.viewbinding

	implementation libs.hilt.android
	ksp libs.hilt.compiler
	implementation libs.androidx.hilt.work
	ksp libs.androidx.hilt.compiler

	implementation libs.coil.core
	implementation libs.coil.network
	implementation libs.coil.gif
	implementation libs.coil.svg
	implementation libs.avif.decoder
	implementation libs.ssiv
	implementation libs.disk.lru.cache
	implementation libs.markwon
	implementation libs.kizzyrpc

	implementation libs.acra.http
	implementation libs.acra.dialog

	implementation libs.conscrypt.android

	debugImplementation libs.leakcanary.android
	debugImplementation libs.workinspector

	testImplementation libs.junit
	testImplementation libs.json
	testImplementation libs.kotlinx.coroutines.test

	androidTestImplementation libs.androidx.runner
	androidTestImplementation libs.androidx.rules
	androidTestImplementation libs.androidx.test.core
	androidTestImplementation libs.androidx.junit

	androidTestImplementation libs.kotlinx.coroutines.test

	androidTestImplementation libs.androidx.room.testing
	androidTestImplementation libs.moshi.kotlin

	androidTestImplementation libs.hilt.android.testing
	kspAndroidTest libs.hilt.android.compiler
}
