Skip to content

Instantly share code, notes, and snippets.

View SergeiMikhailovskii's full-sized avatar
🦁
Lion on the jeep

Sergei Mikhailovskii SergeiMikhailovskii

🦁
Lion on the jeep
View GitHub Profile
plugins {
id("com.mikhailovskii.kmp.module")
id("maven-publish")
}
kotlin {
sourceSets {
androidMain.dependencies {
implementation(libs.rustore.review)
}
internal fun ExtensionContainer.getPluginId(alias: String): String =
getByType<VersionCatalogsExtension>().named("libs").findPlugin(alias).get().get().pluginId
internal fun ExtensionContainer.getVersion(alias: String): String =
getByType<VersionCatalogsExtension>().named("libs").findVersion(alias).get().toString()
class KMPModuleConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply(extensions.getPluginId("androidLibrary"))
apply(extensions.getPluginId("kotlinMultiplatform"))
apply("maven-publish")
}
group = "com.mikhailovskii.kmp"
version = System.getenv("LIBRARY_VERSION") ?: extensions.getVersion("pluginVersion")
plugins {
`kotlin-dsl`
}
gradlePlugin {
plugins {
register("com.mikhailovskii.kmp.KMPModuleConventionPlugin") {
id = "com.mikhailovskii.kmp.module"
implementationClass = "KMPModuleConventionPlugin"
}
dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
plugins {
id("com.mikhailovskii.kmp.module")
id("maven-publish")
}
kotlin {
sourceSets {
androidMain.dependencies {
implementation(libs.rustore.review)
}
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
id("maven-publish")
}
group = "com.mikhailovskii.kmp"
version = System.getenv("LIBRARY_VERSION") ?: libs.versions.pluginVersion.get()
kotlin {
internal class RuStoreExceptionMapper {
operator fun invoke(throwable: RuStoreException) = when (throwable) {
is RuStoreNotInstalledException -> ReviewCode.STORE_NOT_FOUND
is RuStoreOutdatedException -> ReviewCode.STORE_OUTDATED
is RuStoreUserBannedException -> ReviewCode.USER_BANNED
is RuStoreApplicationBannedException -> ReviewCode.APP_BANNED
is RuStoreRequestLimitReached -> ReviewCode.REQUEST_LIMIT_REACHED
is RuStoreReviewExists -> ReviewCode.REVIEW_EXISTS
is RuStoreInvalidReviewInfo -> ReviewCode.INVALID_REVIEW_INFO
else -> throw throwable
class RuStoreInAppReviewInitParams(val context: Context)
class RuStoreInAppReviewManager(private val params: RuStoreInAppReviewInitParams) : InAppReviewDelegate {
override fun requestInAppReview() = flow {
val activity = params.context
val manager = RuStoreReviewManagerFactory.create(activity)
val reviewInfo = manager.requestReviewFlow().await()
manager.launchReviewFlow(reviewInfo).await()
emit(ReviewCode.NO_ERROR)
maven("https://artifactory-external.vkpartner.ru/artifactory/maven")