Skip to content

Commit

Permalink
Introduce version catalogs & remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsinghmutualmobile committed Oct 25, 2024
1 parent ef1d335 commit 60d7b40
Show file tree
Hide file tree
Showing 40 changed files with 184 additions and 345 deletions.
11 changes: 4 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
buildscript {
val compose_version by extra("1.7.4")
val wear_compose_version by extra("1.4.0")
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.7.1" apply false
id("com.android.library") version "8.7.1" apply false
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.composePlugin) apply false
alias(libs.plugins.kotlinAndroid) apply false
}
50 changes: 20 additions & 30 deletions composesensors/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.vanniktech.maven.publish") version "0.30.0"
alias(libs.plugins.androidLibrary)
alias(libs.plugins.composePlugin)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.mavenPublish)
}

android {
namespace = "com.mutualmobile.composesensors"
compileSdk = 34

compileSdk = libs.versions.targetSdk.get().toInt()
defaultConfig {
minSdk = 21

minSdk = libs.versions.minSdk.get().toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
Expand All @@ -25,35 +23,27 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "11"
jvmTarget = libs.versions.jvmTarget.get()
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
}

dependencies {
val coreKtxVersion = "1.13.1"
val appCompatVersion = "1.7.0"
val materialVersion = "1.12.0"
val jUnitVersion = "4.13.2"
val androidJUnitVersion = "1.2.1"
val espressoVersion = "3.6.1"
val composeVersion = "1.7.4"

implementation("androidx.compose.runtime:runtime:$composeVersion")
implementation("androidx.compose.ui:ui:$composeVersion")
implementation("androidx.core:core-ktx:$coreKtxVersion")
implementation("androidx.appcompat:appcompat:$appCompatVersion")
implementation("com.google.android.material:material:$materialVersion")
testImplementation("junit:junit:$jUnitVersion")
androidTestImplementation("androidx.test.ext:junit:$androidJUnitVersion")
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
androidTestImplementation(libs.espresso)
androidTestImplementation(libs.junit.android)
androidTestImplementation(platform(libs.compose.bom))
implementation(libs.androidCore)
implementation(libs.appCompat)
implementation(libs.compose.runtime)
implementation(libs.compose.ui)
implementation(libs.material)
implementation(platform(libs.compose.bom))
testImplementation(libs.junit)
testImplementation(platform(libs.compose.bom))
}

This file was deleted.

This file was deleted.

55 changes: 55 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[versions]
agp = "8.7.1"
android-lifecycle-runtime = "2.8.6"
androidCore = "1.13.1"
appCompat = "1.7.0"
compose-wear = "1.4.0"
composeActivity = "1.9.3"
composeBom = "2024.10.00"
espresso = "3.6.1"
junit = "4.13.2"
junit-android = "1.2.1"
jvmTarget = "17"
kotlin = "2.0.21"
legacySupport = "1.0.0"
material = "1.12.0"
mavenPublish = "0.30.0"
minSdk = "21"
minSdkWear = "26"
percentLayout = "1.0.0"
playServicesWearable = "18.2.0"
splashScreen = "1.0.1"
targetSdk = "35"

[libraries]
android-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "android-lifecycle-runtime" }
android-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "android-lifecycle-runtime" }
androidCore = { module = "androidx.core:core-ktx", version.ref = "androidCore" }
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" }
compose-activity = { module = "androidx.activity:activity-compose", version.ref = "composeActivity" }
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" }
compose-material3 = { module = "androidx.compose.material3:material3" }
compose-runtime = { module = "androidx.compose.runtime:runtime" }
compose-ui = { module = "androidx.compose.ui:ui" }
compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
compose-wear-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "compose-wear" }
compose-wear-material = { module = "androidx.wear.compose:compose-material", version.ref = "compose-wear" }
espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
junit = { module = "junit:junit", version.ref = "junit" }
junit-android = { module = "androidx.test.ext:junit", version.ref = "junit-android" }
junit-compose = { module = "androidx.compose.ui:ui-test-junit4" }
legacySupport = { module = "androidx.legacy:legacy-support-v4", version.ref = "legacySupport" }
material = { module = "com.google.android.material:material", version.ref = "material" }
percentLayout = { module = "androidx.percentlayout:percentlayout", version.ref = "percentLayout" }
playServicesWearable = { module = "com.google.android.gms:play-services-wearable", version.ref = "playServicesWearable" }
splashScreen = { module = "androidx.core:core-splashscreen", version.ref = "splashScreen" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
composePlugin = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
74 changes: 32 additions & 42 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import java.util.Properties

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.androidApplication)
alias(libs.plugins.composePlugin)
alias(libs.plugins.kotlinAndroid)
}

android {
namespace = "com.mutualmobile.sample"
compileSdk = 34

compileSdk = libs.versions.targetSdk.get().toInt()
defaultConfig {
applicationId = "com.mutualmobile.sample"
minSdk = 21
targetSdk = 34
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

signingConfigs {
val propertiesFile = File("keystore.properties")
if (propertiesFile.exists()) {
Expand All @@ -37,31 +35,30 @@ android {
}
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
runCatching { signingConfigs.getByName("release") }
.onSuccess { safeConfig -> signingConfig = safeConfig }
runCatching {
signingConfigs.getByName("release")
}.onSuccess { config ->
signingConfig = config
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "11"
jvmTarget = libs.versions.jvmTarget.get()
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand All @@ -70,29 +67,22 @@ android {
}

dependencies {
val composeVersion = "1.7.4"
val material3Version = "1.3.0"
val lifecycleRuntimeKtxVersion = "2.8.6"
val coreKtxVersion = "1.13.1"
val activityComposeVersion = "1.9.3"
val jUnitVersion = "4.13.2"
val androidJUnitVersion = "1.2.1"
val espressoVersion = "3.6.1"
val splashScreenVersion = "1.0.1"

implementation(project(mapOf("path" to ":composesensors")))
implementation("androidx.core:core-ktx:$coreKtxVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleRuntimeKtxVersion")
implementation("androidx.activity:activity-compose:$activityComposeVersion")
implementation("androidx.compose.ui:ui:$composeVersion")
implementation("androidx.compose.ui:ui-graphics:$composeVersion")
implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion")
implementation("androidx.compose.material3:material3:$material3Version")
testImplementation("junit:junit:$jUnitVersion")
androidTestImplementation("androidx.test.ext:junit:$androidJUnitVersion")
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")
debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion")
implementation("androidx.core:core-splashscreen:$splashScreenVersion")
androidTestImplementation(libs.espresso)
androidTestImplementation(libs.junit.android)
androidTestImplementation(libs.junit.compose)
androidTestImplementation(platform(libs.compose.bom))
debugImplementation(libs.compose.ui.testManifest)
debugImplementation(libs.compose.ui.tooling)
implementation(libs.android.lifecycle.runtime)
implementation(libs.androidCore)
implementation(libs.compose.activity)
implementation(libs.compose.material3)
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.splashScreen)
implementation(platform(libs.compose.bom))
implementation(project(":composesensors"))
testImplementation(libs.junit)
testImplementation(platform(libs.compose.bom))
}

This file was deleted.

7 changes: 3 additions & 4 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@
android:theme="@style/Theme.App.Starting"
tools:targetApi="31">
<activity
android:name="com.mutualmobile.sample.MainActivity"
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/Theme.App.Starting"
tools:ignore="LockedOrientationActivity">
tools:ignore="DiscouragedApi,LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import com.mutualmobile.sample.ui.ComposeSensorsTheme
import com.mutualmobile.sample.ui.screens.sensorlist.SensorsListScreen
import com.mutualmobile.sample.ui.theme.ComposeSensorsTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Loading

0 comments on commit 60d7b40

Please sign in to comment.