diff --git a/androidModules/utils/.gitignore b/androidModules/utils/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/androidModules/utils/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/androidModules/utils/build.gradle.kts b/androidModules/utils/build.gradle.kts new file mode 100644 index 0000000..791b79a --- /dev/null +++ b/androidModules/utils/build.gradle.kts @@ -0,0 +1,44 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlinAndroid) +} + +android { + namespace = "cl.carlost.androidutils" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + + implementation(libs.core.ktx) + implementation(libs.appcompat) + implementation(libs.material) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/androidModules/utils/consumer-rules.pro b/androidModules/utils/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/androidModules/utils/proguard-rules.pro b/androidModules/utils/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/androidModules/utils/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/androidModules/utils/src/androidTest/java/cl/carlost/androidutils/ExampleInstrumentedTest.kt b/androidModules/utils/src/androidTest/java/cl/carlost/androidutils/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..db7e6f6 --- /dev/null +++ b/androidModules/utils/src/androidTest/java/cl/carlost/androidutils/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package cl.carlost.androidutils + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("cl.carlost.androidutils.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/androidModules/utils/src/main/AndroidManifest.xml b/androidModules/utils/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a5918e6 --- /dev/null +++ b/androidModules/utils/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/androidModules/utils/src/test/java/cl/carlost/androidutils/ExampleUnitTest.kt b/androidModules/utils/src/test/java/cl/carlost/androidutils/ExampleUnitTest.kt new file mode 100644 index 0000000..322b628 --- /dev/null +++ b/androidModules/utils/src/test/java/cl/carlost/androidutils/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package cl.carlost.androidutils + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9c4d0da..25686d8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,6 +5,12 @@ compose = "1.5.4" compose-compiler = "1.5.4" compose-material3 = "1.1.2" androidx-activityCompose = "1.8.0" +core-ktx = "1.12.0" +junit = "4.13.2" +androidx-test-ext-junit = "1.1.5" +espresso-core = "3.5.1" +appcompat = "1.6.1" +material = "1.11.0" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -14,6 +20,12 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } +core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } +espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } +appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 37cb1e8..9fd1439 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,4 +16,5 @@ dependencyResolutionManagement { rootProject.name = "KMPExcercises" include(":androidApp") -include(":shared") \ No newline at end of file +include(":shared") +include(":androidModules:utils")