apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'de.mannodermaus.android-junit5'

android {
	defaultPublishConfig "debug"

	def globalConfiguration = rootProject.extensions.getByName("ext")

	compileSdkVersion globalConfiguration["androidCompileSdkVersion"]
	buildToolsVersion globalConfiguration["androidBuildToolsVersion"]

	defaultConfig {
		minSdkVersion globalConfiguration["androidMinSdkVersion"]
		targetSdkVersion globalConfiguration["androidTargetSdkVersion"]

		buildConfigField 'int', 'VERSION_CODE', "${globalConfiguration["androidVersionCode"]}"
		buildConfigField "String", "VERSION_NAME", "\"${globalConfiguration["androidVersionName"]}\""

		testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
	}

	compileOptions {
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
	}

	lintOptions {
		quiet true
		abortOnError false
		ignoreWarnings true
	}

	packagingOptions {
		pickFirst 'META-INF/*'
	}
}

dependencies {
	def dependencies = rootProject.ext.dependencies
	// cryptomator
	api dependencies.cryptolib
	api dependencies.dagger
	api dependencies.timber
	api dependencies.appcompat
	api dependencies.androidAnnotations

	implementation dependencies.lruFileCache

	implementation dependencies.androidxPreference

	// test
	androidTestImplementation dependencies.androidxTestCore
	androidTestImplementation(dependencies.runner) {
		exclude group: 'com.android.support', module: 'support-annotations'
	}

	androidTestImplementation(dependencies.rules) {
		exclude group: 'com.android.support', module: 'support-annotations'
	}

	testImplementation dependencies.junit
	testImplementation dependencies.junitApi
	testRuntimeOnly dependencies.junitEngine
	testImplementation dependencies.junitParams

	testImplementation dependencies.junit4
	testRuntimeOnly dependencies.junit4Engine

	testImplementation dependencies.hamcrest
	testImplementation dependencies.mockito
	testImplementation dependencies.mockitoKotlin
	testImplementation dependencies.mockitoInline

	implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

tasks.withType(Test) {
	testLogging {
		events "failed"

		showExceptions true
		exceptionFormat "full"
		showCauses true
		showStackTraces true

		showStandardStreams = false
	}
}
