migrate gradle to kts and version catalog

This commit is contained in:
Stefano Sansone 2024-02-15 00:23:31 +00:00
parent 5427295fdd
commit dc617ffaff
8 changed files with 296 additions and 214 deletions

View file

@ -1,179 +0,0 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id("com.apollographql.apollo3") version "3.8.2"
}
def keystorePropertiesFile = rootProject.file("app/external/keystore.properties")
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdk 34
defaultConfig {
applicationId "app.omnivore.omnivore"
minSdk 26
targetSdk 34
versionCode 189
versionName "0.189.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
signingConfigs {
release {
keyAlias 'key0'
storeFile file('external/omnivore-prod.keystore')
storePassword keystoreProperties['prodStorePassword']
keyPassword keystoreProperties['prodKeyPassword']
}
debug {
if (keystoreProperties['demoStorePassword'] && keystoreProperties['demoKeyPassword']) {
keyAlias 'androiddebugkey'
storeFile file('external/omnivore-demo.keystore')
storePassword keystoreProperties['demoStorePassword']
keyPassword keystoreProperties['demoKeyPassword']
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
applicationIdSuffix ".debug"
buildConfigField("String", "OMNIVORE_API_URL", "\"https://api-demo.omnivore.app\"")
buildConfigField("String", "OMNIVORE_WEB_URL", "\"https://demo.omnivore.app\"")
buildConfigField("String", "OMNIVORE_GAUTH_SERVER_CLIENT_ID", "\"267918240109-eu2ar09unac3lqqigluknhk7t0021b54.apps.googleusercontent.com\"")
}
release {
minifyEnabled false
signingConfig signingConfigs.release
buildConfigField("String", "OMNIVORE_API_URL", "\"https://api-prod.omnivore.app\"")
buildConfigField("String", "OMNIVORE_WEB_URL", "\"https://omnivore.app\"")
buildConfigField("String", "OMNIVORE_GAUTH_SERVER_CLIENT_ID", "\"687911924401-lq8j1e97n0sv3khhb8g8n368lk4dqkbp.apps.googleusercontent.com\"")
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose true
buildConfig true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.8"
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
namespace "app.omnivore.omnivore"
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.gms:play-services-base:18.3.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
// Compose
def composeBom = platform('androidx.compose:compose-bom:2024.01.00')
implementation(composeBom)
androidTestImplementation(composeBom)
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.ui:ui:")
implementation("androidx.compose.material:material")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.navigation:navigation-compose:2.7.6")
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
// Testing
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
// ViewModel utilities for Compose
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version")
// LiveData
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
implementation("androidx.compose.runtime:runtime-livedata:1.6.0")
// Saved state module for ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version")
// Annotation processor
implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
// coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation "androidx.security:security-crypto:1.0.0"
implementation "androidx.datastore:datastore-preferences:1.0.0"
// Dagger - Hilt
implementation("com.google.dagger:hilt-android:$hilt_version")
kapt("com.google.dagger:hilt-compiler:$hilt_version")
implementation("com.apollographql.apollo3:apollo-runtime:3.8.2")
implementation("com.google.android.gms:play-services-auth:20.7.0")
implementation("com.google.accompanist:accompanist-systemuicontroller:0.34.0")
implementation("com.google.accompanist:accompanist-flowlayout:0.32.0")
implementation("io.coil-kt:coil-compose:2.5.0")
implementation("com.google.code.gson:gson:2.10")
implementation("com.pspdfkit:pspdfkit:8.9.1")
implementation("com.posthog.android:posthog:2.0.3")
implementation("io.intercom.android:intercom-sdk:15.1.0")
// Room Deps
implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
annotationProcessor("androidx.room:room-compiler:$room_version")
kapt("androidx.room:room-compiler:$room_version")
implementation("com.github.jeziellago:compose-markdown:0.3.3")
implementation("io.github.dokar3:chiptextfield-m3:0.6.5")
}
apollo {
packageName.set "app.omnivore.omnivore.graphql.generated"
}
task printVersion {
doLast {
println "omnivoreVersion: ${android.defaultConfig.versionName}"
}
}

View file

@ -0,0 +1,183 @@
import java.io.FileInputStream
import java.util.Properties
plugins {
alias(libs.plugins.android.application)
kotlin("android")
id("dagger.hilt.android.plugin")
alias(libs.plugins.ksp)
alias(libs.plugins.apollo)
}
val keystorePropertiesFile = rootProject.file("app/external/keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
FileInputStream(keystorePropertiesFile).use { input ->
keystoreProperties.load(input)
}
}
android {
namespace = "app.omnivore.omnivore"
compileSdk = 34
defaultConfig {
applicationId = "app.omnivore.omnivore"
minSdk = 26
targetSdk = 34
versionCode = 190
versionName = "0.190.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
signingConfigs {
create("release") {
keyAlias = "key0"
storeFile = file("external/omnivore-prod.keystore")
storePassword = keystoreProperties["prodStorePassword"] as String?
keyPassword = keystoreProperties["prodKeyPassword"] as String?
}/* debug {
if (keystoreProperties["demoStorePassword"] && keystoreProperties["demoKeyPassword"]) {
keyAlias = "androiddebugkey"
storeFile = file("external/omnivore-demo.keystore")
storePassword = keystoreProperties["demoStorePassword"] as String
keyPassword = keystoreProperties["demoKeyPassword"] as String
}
}*/
}
buildTypes {
debug {
signingConfig = signingConfigs.getByName("debug")
applicationIdSuffix = ".debug"
buildConfigField("String", "OMNIVORE_API_URL", "\"https://api-demo.omnivore.app\"")
buildConfigField("String", "OMNIVORE_WEB_URL", "\"https://demo.omnivore.app\"")
buildConfigField(
"String",
"OMNIVORE_GAUTH_SERVER_CLIENT_ID",
"\"267918240109-eu2ar09unac3lqqigluknhk7t0021b54.apps.googleusercontent.com\""
)
}
release {
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("release")
buildConfigField("String", "OMNIVORE_API_URL", "\"https://api-prod.omnivore.app\"")
buildConfigField("String", "OMNIVORE_WEB_URL", "\"https://omnivore.app\"")
buildConfigField(
"String",
"OMNIVORE_GAUTH_SERVER_CLIENT_ID",
"\"687911924401-lq8j1e97n0sv3khhb8g8n368lk4dqkbp.apps.googleusercontent.com\""
)
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get()
}
packaging {
resources {
excludes += listOf("/META-INF/{AL2.0,LGPL2.1}")
}
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.gms.playServicesBase)
implementation(libs.gms.playServicesAuth)
val bom = platform(libs.androidx.compose.bom)
implementation(bom)
androidTestImplementation(bom)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.ui.util)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.navigation.compose)
androidTestImplementation(libs.androidx.compose.ui.test)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.testManifest)
testImplementation(libs.junit4)
androidTestImplementation(libs.androidx.test.ext)
androidTestImplementation(libs.androidx.test.espresso.core)
implementation(libs.androidx.lifecycle.viewModelKtx)
implementation(libs.androidx.lifecycle.viewModelCompose)
implementation(libs.androidx.lifecycle.viewmodelSavedstate)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.compose.runtime.livedata)
implementation(libs.retrofit.core)
implementation(libs.retrofit.converter.gson)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.androidx.security.crypto)
implementation(libs.androidx.dataStore.preferences)
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
implementation(libs.apollo.runtime)
// TODO: Remove in favor of new Compose libs
implementation(libs.accompanist.systemuicontroller)
implementation(libs.accompanist.flowlayout)
implementation(libs.coil.kt.compose)
implementation(libs.room.runtime)
implementation(libs.room.ktx)
annotationProcessor(libs.room.compiler)
ksp(libs.room.compiler)
implementation(libs.gson)
implementation(libs.pspdfkit)
implementation(libs.posthog)
implementation(libs.intercom)
implementation(libs.compose.markdown)
implementation(libs.chiptextfield.m3)
}
apollo {
service("service") {
outputDirConnection {
connectToKotlinSourceSet("main")
}
packageName.set("app.omnivore.omnivore.graphql.generated")
}
}
tasks.register("printVersion") {
doLast {
println("omnivoreVersion: ${android.defaultConfig.versionName}")
}
}

View file

@ -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
@ -18,4 +18,4 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

View file

@ -131,7 +131,7 @@ fun LibraryNavigationBar(
contentDescription = null
)
}
IconButton(onClick = { isMenuExpanded = true } ) {
/* IconButton(onClick = { isMenuExpanded = true } ) {
Icon(
imageVector = Icons.Default.MoreVert,
contentDescription = null
@ -144,7 +144,7 @@ fun LibraryNavigationBar(
onDismiss = { isMenuExpanded = false },
)
}
}
}*/
} ?: run {
IconButton(onClick = onSearchClicked) {
Icon(

View file

@ -1,29 +0,0 @@
buildscript {
ext {
lifecycle_version = "2.7.0"
hilt_version = "2.50"
gradle_plugin_version = '8.2.2'
room_version = "2.6.1"
kotlin_version = '1.7.10'
}
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "com.android.tools.build:gradle:$gradle_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
repositories {
mavenCentral()
}
}
plugins {
id 'com.android.application' version "$gradle_plugin_version" apply false
id 'com.android.library' version "$gradle_plugin_version" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View file

@ -0,0 +1,22 @@
buildscript {
dependencies {
classpath(libs.android.hilt)
classpath(libs.android.gradlePlugin)
classpath(libs.kotlin.gradlePlugin)
}
repositories {
mavenCentral()
google()
}
}
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.ksp) apply false
}
task<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

View file

@ -0,0 +1,85 @@
[versions]
accompanistSystemUiController = "0.34.0"
accompanistFlowLayout = "0.32.0"
androidGradlePlugin = "8.2.2"
androidxActivity = "1.8.2"
androidxAppCompat = "1.6.1"
androidxComposeBom = "2024.02.00"
androidxComposeCompiler = "1.5.9"
androidxCore = "1.12.0"
androidxDataStore = "1.0.0"
androidxEspresso = "3.5.1"
androidxLifecycle = "2.7.0"
androidxNavigation = "2.7.7"
androidxSecurity = "1.0.0"
androidxTestExt = "1.1.5"
apollo = "3.8.2"
chiptextfieldM3 = "0.6.5"
coil = "2.5.0"
composeMarkdown = "0.3.3"
gson = "2.10.1"
hilt = "2.50"
intercom = "15.1.0"
junit4 = "4.13.2"
kotlin = "1.9.22"
ksp = "1.9.22-1.0.17"
kotlinxCoroutines = "1.7.3"
playServices = "18.3.0"
playServicesAuth = "20.7.0"
posthog = "2.0.3"
pspdfkit = "8.9.1"
retrofit = "2.9.0"
room = "2.6.1"
[libraries]
accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanistSystemUiController" }
accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanistFlowLayout" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" }
androidx-compose-material = { group = "androidx.compose.material", name = "material" }
androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-compose-runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata" }
androidx-compose-ui-test = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-compose-ui-testManifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-compose-ui-util = { group = "androidx.compose.ui", name = "ui-util" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }
androidx-dataStore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "androidxDataStore" }
androidx-lifecycle-viewModelKtx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "androidxLifecycle" }
androidx-lifecycle-viewModelCompose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "androidxLifecycle" }
androidx-lifecycle-viewmodelSavedstate = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-savedstate", version.ref = "androidxLifecycle" }
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" }
androidx-security-crypto = { group = "androidx.security", name = "security-crypto", version.ref = "androidxSecurity" }
androidx-test-ext = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxTestExt" }
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidxEspresso" }
apollo-runtime = { group = "com.apollographql.apollo3", name = "apollo-runtime", version.ref = "apollo" }
chiptextfield-m3 = { group = "io.github.dokar3", name = "chiptextfield-m3", version.ref = "chiptextfieldM3" }
coil-kt-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" }
compose-markdown = { group = "com.github.jeziellago", name = "compose-markdown", version.ref = "composeMarkdown" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
gms-playServicesAuth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "playServicesAuth" }
gms-playServicesBase = { group = "com.google.android.gms", name = "play-services-base", version.ref = "playServices" }
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
intercom = { group = "io.intercom.android", name = "intercom-sdk", version.ref = "intercom" }
junit4 = { group = "junit", name = "junit", version.ref = "junit4" }
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
posthog = { group = "com.posthog.android", name = "posthog", version.ref = "posthog" }
pspdfkit = { group = "com.pspdfkit", name = "pspdfkit", version.ref = "pspdfkit" }
retrofit-converter-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit" }
retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" }
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
android-hilt = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "hilt" }
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
apollo = { id = "com.apollographql.apollo3", version.ref = "apollo" }

View file

@ -1,6 +1,6 @@
#Thu Feb 01 13:22:21 GMT 2024
#Wed Feb 14 01:21:10 GMT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists