diff --git a/core/common/.gitignore b/core/common/.gitignore new file mode 100644 index 00000000..58b7a5c1 --- /dev/null +++ b/core/common/.gitignore @@ -0,0 +1,3 @@ +/build +/consumer-rules.pro +/proguard-rules.pro \ No newline at end of file diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts new file mode 100644 index 00000000..47e706c4 --- /dev/null +++ b/core/common/build.gradle.kts @@ -0,0 +1,13 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + id("stackknowledge.android.core") + id("stackknowledge.android.hilt") +} + +android { + namespace = "com.stackknowledge.common" +} + +dependencies { + testImplementation(libs.kotlinx.coroutines.test) +} \ No newline at end of file diff --git a/core/common/src/androidTest/java/com/example/common/ExampleInstrumentedTest.kt b/core/common/src/androidTest/java/com/example/common/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..0886bf66 --- /dev/null +++ b/core/common/src/androidTest/java/com/example/common/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.common + +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("com.example.common.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/core/common/src/main/AndroidManifest.xml b/core/common/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/core/common/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/core/network/src/main/kotlin/com/stackknowledge/exception/HttpException.kt b/core/common/src/main/java/com/example/common/exception/HttpException.kt similarity index 95% rename from core/network/src/main/kotlin/com/stackknowledge/exception/HttpException.kt rename to core/common/src/main/java/com/example/common/exception/HttpException.kt index 1e739e5a..5ad16abb 100644 --- a/core/network/src/main/kotlin/com/stackknowledge/exception/HttpException.kt +++ b/core/common/src/main/java/com/example/common/exception/HttpException.kt @@ -1,4 +1,4 @@ -package com.stackknowledge.exception +package com.example.common.exception class BadRequestException( override val message: String? diff --git a/core/network/src/main/kotlin/com/stackknowledge/exception/NeedLoginException.kt b/core/common/src/main/java/com/example/common/exception/NeedLoginException.kt similarity index 83% rename from core/network/src/main/kotlin/com/stackknowledge/exception/NeedLoginException.kt rename to core/common/src/main/java/com/example/common/exception/NeedLoginException.kt index 4317b807..87ff5abb 100644 --- a/core/network/src/main/kotlin/com/stackknowledge/exception/NeedLoginException.kt +++ b/core/common/src/main/java/com/example/common/exception/NeedLoginException.kt @@ -1,4 +1,4 @@ -package com.stackknowledge.exception +package com.example.common.exception import java.io.IOException diff --git a/core/network/src/main/kotlin/com/stackknowledge/exception/NetworkException.kt b/core/common/src/main/java/com/example/common/exception/NetworkException.kt similarity index 84% rename from core/network/src/main/kotlin/com/stackknowledge/exception/NetworkException.kt rename to core/common/src/main/java/com/example/common/exception/NetworkException.kt index 9f2b3780..53a40d05 100644 --- a/core/network/src/main/kotlin/com/stackknowledge/exception/NetworkException.kt +++ b/core/common/src/main/java/com/example/common/exception/NetworkException.kt @@ -1,4 +1,4 @@ -package com.stackknowledge.exception +package com.example.common.exception class NetworkException : RuntimeException() { override val message: String diff --git a/core/common/src/test/java/com/example/common/ExampleUnitTest.kt b/core/common/src/test/java/com/example/common/ExampleUnitTest.kt new file mode 100644 index 00000000..6c9f3e0c --- /dev/null +++ b/core/common/src/test/java/com/example/common/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.example.common + +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/core/network/build.gradle.kts b/core/network/build.gradle.kts index 3c87ed39..bc49f9e4 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -20,6 +20,7 @@ android { } dependencies { + implementation(project(":core:common")) implementation(project(":core:model")) implementation(project(":core:datastore")) diff --git a/core/network/src/main/kotlin/com/stackknowledge/util/StackKnowledgeApiHandler.kt b/core/network/src/main/kotlin/com/stackknowledge/util/StackKnowledgeApiHandler.kt index d047e789..e52ac83c 100644 --- a/core/network/src/main/kotlin/com/stackknowledge/util/StackKnowledgeApiHandler.kt +++ b/core/network/src/main/kotlin/com/stackknowledge/util/StackKnowledgeApiHandler.kt @@ -3,7 +3,7 @@ package com.stackknowledge.util import android.net.http.NetworkException import android.os.Build import androidx.annotation.RequiresExtension -import com.stackknowledge.exception.* +import com.example.common.exception.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import retrofit2.HttpException diff --git a/settings.gradle.kts b/settings.gradle.kts index d09760bb..219dc1a4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,6 +17,7 @@ dependencyResolutionManagement { rootProject.name = "StackKnowledge" include(":app") +include(":core:common") include(":core:data") include(":core:datastore") include(":core:design-system")