buildscript { ext { lifecycle = '2.5.1' retrofit = "2.9.0" okHttp = "4.10.0" rxBindings = "4.0.0" glide = "4.14.2" constraint_layout = '2.1.4' coroutines = '1.6.4' nav_version = '2.5.3' rx = '3.0.1' material = "1.7.0" moshi = "1.14.0" fragment = "1.5.4" activity = "1.6.1" appCompat = "1.5.1" coreKTX = "1.9.0" securityVersion = "1.1.0-alpha04" recyclerview = '1.2.1' annotationVersion = '1.5.0' documentFile = '1.0.1' swipeRefresh = '1.1.0' viewPager = '1.0.0' biometrics = '1.2.0-alpha05' joda = '2.12.1' exifinterface= '1.3.5' palette = '1.0.0' preference = '1.2.0' collection = '1.2.0' interpolator = '1.0.0' transition = '1.4.1' //app only room_version = "2.4.3" //tests junitVersion = '4.13.2' hamcrestVersion = '1.3' androidXTestCoreVersion = '1.4.0' androidXTestExtKotlinRunnerVersion = '1.1.4' androidXTestRulesVersion = '1.2.0-beta01' robolectricVersion = '4.9' archTestingVersion = '2.1.0' espressoVersion = '3.4.0' //compilation compileVersion = 33 minVersion = 23 verCode = 1 verName = "1.0.0" testRunner = "androidx.test.runner.AndroidJUnitRunner" kotlin_version = '1.7.21' } repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { group = "io.github.funkymuse" repositories { google() mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir } subprojects { switch (it.name) { case "app": apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-parcelize' dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) } applyAndroid(it, true) break case ["enums", "regex"]: apply plugin: 'java-library' apply plugin: 'kotlin' applyKotlinModule(it) break default: //setup gradle for libraries apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'maven-publish' apply plugin: 'kotlin-parcelize' applyAndroid(it, false) dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) // Dependencies for local unit tests testImplementation "junit:junit:$junitVersion" testImplementation "org.hamcrest:hamcrest-all:$hamcrestVersion" testImplementation "androidx.test.ext:junit-ktx:$androidXTestExtKotlinRunnerVersion" testImplementation "androidx.test:core-ktx:$androidXTestCoreVersion" testImplementation "org.robolectric:robolectric:$robolectricVersion" testImplementation "androidx.arch.core:core-testing:$archTestingVersion" testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines" // AndroidX Test - Instrumented testing androidTestImplementation "androidx.test.ext:junit:$androidXTestExtKotlinRunnerVersion" androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion" } it.afterEvaluate { publishing { publications { release(MavenPublication) { from components.release } } } } break } } def applyKotlinModule(project) { project.java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } project.dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } } def applyAndroid(project, buildConfigCase) { project.android { compileSdkVersion compileVersion defaultConfig { minSdkVersion minVersion targetSdkVersion compileVersion versionCode verCode versionName verName testInstrumentationRunner testRunner } compileOptions { sourceCompatibility = 1.8 targetCompatibility = 1.8 } kotlinOptions { jvmTarget = "1.8" } testOptions.unitTests { includeAndroidResources = true } buildFeatures { aidl = false renderScript = false resValues = false shaders = false buildConfig = buildConfigCase } } }