plugins {
	id 'com.android.application'
	id 'kotlin-android'
	id 'kotlin-kapt'
	id 'com.google.devtools.ksp'
	id 'kotlin-parcelize'
	id 'dagger.hilt.android.plugin'
}

android {
	compileSdk = 34
	buildToolsVersion = '34.0.0'
	namespace = 'org.koitharu.kotatsu'

	defaultConfig {
		applicationId 'org.koitharu.kotatsu'
		minSdk = 21
		targetSdk = 34
		versionCode = 603
		versionName = '6.5-b1'
		generatedDensities = []
		testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner'
		ksp {
			arg('room.generateKotlin', 'true')
			arg('room.schemaLocation', "$projectDir/schemas")
		}
		androidResources {
			generateLocaleConfig true
		}
	}
	buildTypes {
		debug {
			applicationIdSuffix = '.debug'
		}
		release {
			minifyEnabled true
			shrinkResources true
			proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
		}
	}
	buildFeatures {
		viewBinding true
		buildConfig true
	}
	sourceSets {
		androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
		main.java.srcDirs += 'src/main/kotlin/'
	}
	compileOptions {
		coreLibraryDesugaringEnabled true
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
	}
	kotlinOptions {
		jvmTarget = JavaVersion.VERSION_1_8.toString()
		freeCompilerArgs += [
			'-opt-in=kotlin.ExperimentalStdlibApi',
			'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
			'-opt-in=kotlinx.coroutines.FlowPreview',
			'-opt-in=kotlin.contracts.ExperimentalContracts',
			'-opt-in=coil.annotation.ExperimentalCoilApi',
		]
	}
	lint {
		abortOnError true
		disable 'MissingTranslation', 'PrivateResource', 'NotifyDataSetChanged', 'SetJavaScriptEnabled'
	}
	testOptions {
		unitTests.includeAndroidResources true
		unitTests.returnDefaultValues false
		kotlinOptions {
			freeCompilerArgs += ['-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi']
		}
	}
}
afterEvaluate {
	compileDebugKotlin {
		kotlinOptions {
			freeCompilerArgs += ['-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi']
		}
	}
}
dependencies {
	//noinspection GradleDependency
	implementation('com.github.KotatsuApp:kotatsu-parsers:d6b578acb0') {
		exclude group: 'org.json', module: 'json'
	}

	coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
	implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.21'
	implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'

	implementation 'androidx.appcompat:appcompat:1.6.1'
	implementation 'androidx.core:core-ktx:1.12.0'
	implementation 'androidx.activity:activity-ktx:1.8.1'
	implementation 'androidx.fragment:fragment-ktx:1.6.2'
	implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
	implementation 'androidx.lifecycle:lifecycle-service:2.6.2'
	implementation 'androidx.lifecycle:lifecycle-process:2.6.2'
	implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
	implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
	implementation 'androidx.recyclerview:recyclerview:1.3.2'
	implementation 'androidx.viewpager2:viewpager2:1.1.0-beta02'
	implementation 'androidx.preference:preference-ktx:1.2.1'
	implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05'
	implementation 'com.google.android.material:material:1.10.0'
	implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.2'

	implementation 'androidx.work:work-runtime:2.9.0'
	//noinspection GradleDependency
	implementation('com.google.guava:guava:32.0.1-android') {
		exclude group: 'com.google.guava', module: 'failureaccess'
		exclude group: 'org.checkerframework', module: 'checker-qual'
		exclude group: 'com.google.j2objc', module: 'j2objc-annotations'
	}

	implementation 'androidx.room:room-runtime:2.6.1'
	implementation 'androidx.room:room-ktx:2.6.1'
	ksp 'androidx.room:room-compiler:2.6.1'

	implementation 'com.squareup.okhttp3:okhttp:4.12.0'
	implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
	implementation 'com.squareup.okio:okio:3.6.0'

	implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.2'
	implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.2'

	implementation 'com.google.dagger:hilt-android:2.49'
	kapt 'com.google.dagger:hilt-compiler:2.49'
	implementation 'androidx.hilt:hilt-work:1.1.0'
	kapt 'androidx.hilt:hilt-compiler:1.1.0'

	implementation 'io.coil-kt:coil-base:2.5.0'
	implementation 'io.coil-kt:coil-svg:2.5.0'
	implementation 'com.github.KotatsuApp:subsampling-scale-image-view:02e6d6cfe9'
	implementation 'com.github.solkin:disk-lru-cache:1.4'
	implementation 'io.noties.markwon:core:4.6.2'

	implementation 'ch.acra:acra-http:5.11.3'
	implementation 'ch.acra:acra-dialog:5.11.3'

	debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'

	testImplementation 'junit:junit:4.13.2'
	testImplementation 'org.json:json:20231013'
	testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'

	androidTestImplementation 'androidx.test:runner:1.5.2'
	androidTestImplementation 'androidx.test:rules:1.5.0'
	androidTestImplementation 'androidx.test:core-ktx:1.5.0'
	androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'

	androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'

	androidTestImplementation 'androidx.room:room-testing:2.6.1'
	androidTestImplementation 'com.squareup.moshi:moshi-kotlin:1.15.0'

	androidTestImplementation 'com.google.dagger:hilt-android-testing:2.49'
	kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.49'
}
