diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index f779edf6..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,170 +0,0 @@ -plugins { - alias(libs.plugins.android.application) - alias(libs.plugins.kotlin.android) - alias(libs.plugins.kotlin.parcelize) - alias(libs.plugins.androidx.navigation) - alias(libs.plugins.hilt) - alias(libs.plugins.protobuf) - alias(libs.plugins.ksp) -} - -android { - signingConfigs { - release { - storeFile file("$rootDir/release/app-release.jks") - storePassword "${project.properties["PINNIT_KEYSTORE_PASSWORD"]}" - keyAlias 'pinnitalias' - keyPassword "${project.properties["PINNIT_KEY_PASSWORD"]}" - } - } - - namespace 'dev.sasikanth.pinnit' - - compileSdk libs.versions.sdk.compile.get().toInteger() - - defaultConfig { - applicationId "dev.sasikanth.pinnit" - minSdk libs.versions.sdk.min.get().toInteger() - targetSdk libs.versions.sdk.target.get().toInteger() - - if (project.properties["VERSION_CODE"] != null) { - versionCode = project.properties["VERSION_CODE"] as Integer - } else { - versionCode = 1 - } - - if (project.properties["VERSION_NAME"] != null) { - versionName = project.properties["VERSION_NAME"] - } else { - versionName = "1.0.0" - } - - testInstrumentationRunner "dev.sasikanth.pinnit.AndroidTestRunner" - - vectorDrawables.useSupportLibrary = true - - ksp { - arg("room.schemaLocation", "$projectDir/schemas".toString()) - arg("room.incremental", "true") - } - } - - sourceSets { - androidTest.assets.srcDirs += files("$projectDir/schemas".toString()) - - String sharedTestDir = 'src/sharedTest/java' - test { - java.srcDir sharedTestDir - } - androidTest { - java.srcDir sharedTestDir - } - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.release - } - debug { - applicationIdSuffix = '.debug' - } - } - buildFeatures { - viewBinding true - } - compileOptions { - coreLibraryDesugaringEnabled true - - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - - // Enabling experimental coroutines APIs - freeCompilerArgs += "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi" - freeCompilerArgs += "-Xopt-in=kotlin.time.ExperimentalTime" - } -} - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}" - } - - // Generates the java Protobuf-lite code for the Protobufs in this project. See - // https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation - // for more information. - generateProtoTasks { - all().each { task -> - task.builtins { - java { - option 'lite' - } - } - } - } -} - -androidComponents { - onVariants(selector().all(), { variant -> - afterEvaluate { - def capName = variant.name.capitalize() - tasks.getByName("ksp${capName}Kotlin") { - setSource(tasks.getByName("generate${capName}Proto").outputs) - } - } - }) -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - coreLibraryDesugaring libs.desugar.JDK - implementation libs.kotlin.stdlib - implementation libs.androidx.appcompat - implementation libs.androidx.corektx - implementation libs.androidx.fragmentktx - implementation libs.androidx.constraintlayout - implementation libs.bundles.androidx.navigation - implementation libs.bundles.androidx.room - ksp libs.androidx.room.compiler - implementation libs.bundles.androidx.lifecycle - implementation libs.androidx.work - implementation libs.material - debugImplementation libs.leakcanary - implementation libs.bundles.coroutines - implementation libs.hilt.android - implementation libs.hilt.work - ksp libs.hilt.android.compiler - ksp libs.hilt.compiler - implementation libs.bundles.mobius - implementation libs.circleImageView - implementation libs.insetterktx - implementation libs.betterLinkMovement - implementation libs.androidx.seekableVD - implementation libs.androidx.datastore - implementation libs.javalite - implementation libs.flowBinding - - testImplementation libs.junit - testImplementation libs.truth - testImplementation libs.androidx.room.testing - testImplementation libs.androidx.core.testing - testImplementation libs.mockito - testImplementation libs.kotlin.coroutines.test - testImplementation libs.mobius.test - testImplementation libs.androidx.datastore - testImplementation(project(":sharedTestCode")) - - androidTestImplementation libs.androidx.room.testing - androidTestImplementation libs.androidx.junit - androidTestImplementation libs.espresso - androidTestImplementation libs.truth - androidTestImplementation libs.androidx.work.testing - androidTestImplementation libs.hilt.testing - kspAndroidTest libs.hilt.android.compiler - androidTestImplementation libs.androidx.datastore - androidTestImplementation(project(":sharedTestCode")) -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..da6b9ecb --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,180 @@ +import com.google.protobuf.gradle.GenerateProtoTask +import org.gradle.kotlin.dsl.support.uppercaseFirstChar + +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.androidx.navigation) + alias(libs.plugins.hilt) + alias(libs.plugins.protobuf) + alias(libs.plugins.ksp) +} + +android { + signingConfigs { + create("release") { + storeFile = file("$rootDir/release/app-release.jks") + storePassword = "${project.properties["PINNIT_KEYSTORE_PASSWORD"]}" + keyAlias = "pinnitalias" + keyPassword = "${project.properties["PINNIT_KEY_PASSWORD"]}" + } + } + + namespace = "dev.sasikanth.pinnit" + + compileSdk = libs.versions.sdk.compile.get().toInt() + + defaultConfig { + applicationId = "dev.sasikanth.pinnit" + minSdk = libs.versions.sdk.min.get().toInt() + targetSdk = libs.versions.sdk.target.get().toInt() + + if (project.properties["VERSION_CODE"] != null) { + versionCode = (project.properties["VERSION_CODE"] as String).toInt() + } else { + versionCode = 1 + } + + if (project.properties["VERSION_NAME"] != null) { + project.properties["VERSION_NAME"] as String + } else { + versionName = "1.0.0" + } + + testInstrumentationRunner = "dev.sasikanth.pinnit.AndroidTestRunner" + + vectorDrawables.useSupportLibrary = true + + ksp { + arg("room.schemaLocation", "$projectDir/schemas".toString()) + arg("room.incremental", "true") + } + } + + sourceSets { + getByName("androidTest").assets.srcDirs( + files("$projectDir/schemas") + ) + + val sharedTestDir = "src/sharedTest/java" + getByName("test") { + java.srcDir(sharedTestDir) + } + getByName("androidTest") { + java.srcDir(sharedTestDir) + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + signingConfig = signingConfigs.getByName("release") + } + debug { + applicationIdSuffix = ".debug" + } + } + buildFeatures { + viewBinding = true + } + compileOptions { + isCoreLibraryDesugaringEnabled = true + + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + + // Enabling experimental coroutines APIs + freeCompilerArgs += "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi" + freeCompilerArgs += "-Xopt-in=kotlin.time.ExperimentalTime" + } +} + +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}" + } + + // Generates the java Protobuf-lite code for the Protobufs in this project. See + // https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation + // for more information. + generateProtoTasks { + all().forEach { task -> + task.builtins { + create("java") { + option("lite") + } + } + } + } +} + +androidComponents { + onVariants(selector().all()) { variant -> + afterEvaluate { + val variantName = variant.name.uppercaseFirstChar() + val protoTask = + project.tasks.getByName("generate${variantName}Proto") as GenerateProtoTask + + project.tasks.getByName("ksp${variantName}Kotlin") { + dependsOn(protoTask) + (this as org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompileTool<*>).setSource( + protoTask.outputBaseDir + ) + } + } + } +} + +dependencies { + coreLibraryDesugaring(libs.desugar.jdk) + implementation(libs.kotlin.stdlib) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.corektx) + implementation(libs.androidx.fragmentktx) + implementation(libs.androidx.constraintlayout) + implementation(libs.bundles.androidx.navigation) + implementation(libs.bundles.androidx.room) + ksp(libs.androidx.room.compiler) + implementation(libs.bundles.androidx.lifecycle) + implementation(libs.androidx.work) + implementation(libs.material) + debugImplementation(libs.leakcanary) + implementation(libs.bundles.coroutines) + implementation(libs.hilt.android) + implementation(libs.hilt.work) + ksp(libs.hilt.android.compiler) + ksp(libs.hilt.compiler) + implementation(libs.bundles.mobius) + implementation(libs.circleImageView) + implementation(libs.insetterktx) + implementation(libs.betterLinkMovement) + implementation(libs.androidx.seekableVD) + implementation(libs.androidx.datastore) + implementation(libs.javalite) + implementation(libs.flowBinding) + + testImplementation(libs.junit) + testImplementation(libs.truth) + testImplementation(libs.androidx.room.testing) + testImplementation(libs.androidx.core.testing) + testImplementation(libs.mockito) + testImplementation(libs.kotlin.coroutines.test) + testImplementation(libs.mobius.test) + testImplementation(libs.androidx.datastore) + testImplementation(projects.sharedTestCode) + + androidTestImplementation(libs.androidx.room.testing) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.espresso) + androidTestImplementation(libs.truth) + androidTestImplementation(libs.androidx.work.testing) + androidTestImplementation(libs.hilt.testing) + kspAndroidTest(libs.hilt.android.compiler) + androidTestImplementation(libs.androidx.datastore) + androidTestImplementation(projects.sharedTestCode) +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b42451..2f9dc5a4 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/sharedTestCode/build.gradle.kts b/sharedTestCode/build.gradle.kts index 4ccdfa28..bbc6152a 100644 --- a/sharedTestCode/build.gradle.kts +++ b/sharedTestCode/build.gradle.kts @@ -31,7 +31,7 @@ android { } dependencies { - implementation(project(":app")) + implementation(projects.app) coreLibraryDesugaring(libs.desugar.jdk)