Skip to content

Commit

Permalink
Add common
Browse files Browse the repository at this point in the history
  • Loading branch information
enotniy committed Feb 14, 2025
1 parent 0643a44 commit 5a3e017
Show file tree
Hide file tree
Showing 23 changed files with 271 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .idea/AndroidProjectSystem.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/mindbox_common.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
maven { url("https://plugins.gradle.org/m2/") }
maven { url("https://developer.huawei.com/repo/") }
maven { url "https://artifactory-external.vkpartner.ru/artifactory/maven" }
gradlePluginPortal()
}
dependencies {
classpath libs.bundles.buildscript.plugins
Expand Down
8 changes: 4 additions & 4 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ buildscript {
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:8.6.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22'
classpath libs.gradle.v881
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.10'
classpath 'com.google.gms:google-services:4.4.0'
classpath 'com.huawei.agconnect:agcp:1.9.1.300'
}
}


plugins {
id 'com.android.application' version '8.6.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'com.android.application' version '8.8.1' apply false
id 'org.jetbrains.kotlin.android' version '2.1.10' apply false
id 'com.google.gms.google-services' version '4.4.0' apply false
}
27 changes: 20 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[versions]
compile_sdk = "34"
build_tools = "34.0.0"
compile_sdk = "35"
build_tools = "35.0.0"
gradle = "8.8.1"
min_sdk = "21"
target_sdk = "34"
target_sdk = "35"

firebase_bom = "32.7.2"
hms_push = "6.11.0.300"
room = "2.6.1"
kotlin = "1.9.22"
gradle_plugin = "8.6.0"
kotlin = "2.1.10"
gradle_plugin = "8.8.1"
gms_play_services_basement = "18.1.0"
gms_play_services_base = "18.0.1"
gms_play_services_ads_identifier = "18.0.1"
Expand All @@ -24,6 +25,7 @@ androidx_annotations = "1.3.0"
constraint_layout = "2.1.4"
threetenapb = "1.4.6"
glide = "4.15.1"
ktor = "3.1.0"

junit = "4.13.2"
androidx_junit = "1.1.3"
Expand All @@ -35,9 +37,15 @@ turbine = "0.12.1"

agcp = "1.6.0.300"
ktlint-plugin = "12.1.1"
ksp = "1.9.22-1.0.17"
ksp = "2.1.10-1.0.30"

pushclient = "6.5.1"
agp = "8.8.1"
kotlin-test = "2.1.10"
runner = "1.6.2"
[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform" }
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library" }

[bundles]
buildscript-plugins = [
Expand Down Expand Up @@ -88,6 +96,9 @@ constraint_layout = { group = "androidx.constraintlayout", name = "constraintlay
threetenabp = { group = "com.jakewharton.threetenabp", name = "threetenabp", version.ref = "threetenapb" }
glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" }
glide_compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }

# RuStore libraries
rustore_pushclient = { module = "ru.rustore.sdk:pushclient", version.ref = "pushclient" }
Expand All @@ -110,4 +121,6 @@ kotlin_gradle_plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", v
google_services = { module = "com.google.gms:google-services", version.ref = "google_services" }
agcp = { module = "com.huawei.agconnect:agcp", version.ref = "agcp" }
ktlint_gradle_plugin = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint-plugin" }
ksp_gradle_plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
ksp_gradle_plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin-test" }
runner = { group = "androidx.test", name = "runner", version.ref = "runner" }
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 07 16:21:11 YEKT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStoreBase=GRADLE_USER_HOME
1 change: 1 addition & 0 deletions mindbox-common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
99 changes: 99 additions & 0 deletions mindbox-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.kotlin.multiplatform.library)
}

kotlin {

// Target declarations - add or remove as needed below. These define
// which platforms this KMP module supports.
// See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets
androidLibrary {
namespace = "cloud.mindbox.mindbox_common"
compileSdk = 35
minSdk = 21

withHostTestBuilder {
}

withDeviceTestBuilder {
sourceSetTreeName = "test"
}.configure {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}

// For iOS targets, this is also where you should
// configure native binary output. For more information, see:
// https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks

// A step-by-step guide on how to include this library in an XCode
// project can be found here:
// https://developer.android.com/kotlin/multiplatform/migrate
val xcfName = "mindbox-commonKit"

iosX64 {
binaries.framework {
baseName = xcfName
}
}

iosArm64 {
binaries.framework {
baseName = xcfName
}
}

iosSimulatorArm64 {
binaries.framework {
baseName = xcfName
}
}

// Source set declarations.
// Declaring a target automatically creates a source set with the same name. By default, the
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
// common to share sources between related targets.
// See: https://kotlinlang.org/docs/multiplatform-hierarchy.html
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlin.stdlib)
implementation(libs.ktor.client.core)
}
}

commonTest {
dependencies {
implementation(libs.kotlin.test)
}
}

androidMain {
dependencies {
// Add Android-specific dependencies here. Note that this source set depends on
// commonMain by default and will correctly pull the Android artifacts of any KMP
// dependencies declared in commonMain.
}
}

getByName("androidDeviceTest") {
dependencies {
implementation(libs.runner)
implementation(libs.test.core)
implementation(libs.androidx.junit)
}
}

iosMain {
dependencies {
// Add iOS-specific dependencies here. This a source set created by Kotlin Gradle
// Plugin (KGP) that each specific iOS target (e.g., iosX64) depends on as
// part of KMP’s default source set hierarchy. Note that this source set depends
// on common by default and will correctly pull the iOS artifacts of any
// KMP dependencies declared in commonMain.
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cloud.mindbox.mindbox_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("cloud.mindbox.mindbox_common.test", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cloud.mindbox.mindbox_common

import kotlin.test.Test
import kotlin.test.assertEquals

/**
* 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)
}
}
4 changes: 4 additions & 0 deletions mindbox-common/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cloud.mindbox.mindbox_common

actual fun platform() = "Android"

actual fun commonVersion() = "1.0.0-" + platform()
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cloud.mindbox.mindbox_common

import io.ktor.client.HttpClient
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText

expect fun platform(): String

expect fun commonVersion(): String

object MindboxCommon {
private val client = HttpClient()

fun commonFunction(): String {
return commonVersion()
}

suspend fun getConfig(): String {
val response = client.get("https://ktor.io/docs/")
return response.bodyAsText()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cloud.mindbox.mindbox_common

actual fun platform() = "iOS"

actual fun commonVersion() = "1.0.0-" + platform()
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ android {
}

dependencies {
implementation(project(path: ':mindbox-common'))

// Implementation dependencies
implementation libs.kotlin.stdlib
Expand Down Expand Up @@ -81,5 +82,4 @@ dependencies {

// Android Test dependencies
androidTestImplementation libs.bundles.androidTest

}
Loading

0 comments on commit 5a3e017

Please sign in to comment.