From d1c96ee2b926ff95d99fa8651bf59792f2c1f3b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 22 Feb 2021 21:01:08 +0600 Subject: [PATCH] first try --- .../libraries/cache/admins/AdminsCacheAPI.kt | 25 ++++---- extensions.gradle | 2 +- mppAndroidProject.gradle | 2 +- mppJavaProject.gradle | 2 +- mppProjectWithSerialization.gradle | 2 +- publish.gradle | 57 +++++++++++++++++++ publish_config.kpsb | 1 + 7 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 publish.gradle create mode 100644 publish_config.kpsb diff --git a/cache/admins/micro_utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/libraries/cache/admins/AdminsCacheAPI.kt b/cache/admins/micro_utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/libraries/cache/admins/AdminsCacheAPI.kt index a891306..bd8e237 100644 --- a/cache/admins/micro_utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/libraries/cache/admins/AdminsCacheAPI.kt +++ b/cache/admins/micro_utils/src/jvmMain/kotlin/dev/inmo/tgbotapi/libraries/cache/admins/AdminsCacheAPI.kt @@ -7,7 +7,8 @@ import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext import dev.inmo.tgbotapi.libraries.cache.admins.micro_utils.DefaultAdminsCacheAPIRepo import dev.inmo.tgbotapi.libraries.cache.admins.micro_utils.DynamicAdminsCacheSettingsAPI -import dev.inmo.tgbotapi.types.toChatId +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember import kotlinx.coroutines.CoroutineScope import kotlinx.serialization.cbor.Cbor import kotlinx.serialization.decodeFromByteArray @@ -20,14 +21,16 @@ private val serializationFormat = Cbor fun AdminsCacheAPI( bot: TelegramBot, database: Database, - scope: CoroutineScope, - repo: dev.inmo.tgbotapi.libraries.cache.admins.DefaultAdminsCacheAPIRepo = DefaultAdminsCacheAPIRepo( + scope: CoroutineScope +) : AdminsCacheAPI = DefaultAdminsCacheAPI( + bot, + DefaultAdminsCacheAPIRepo( ExposedOneToManyKeyValueRepo( database, { long("chatId") }, { blob("member") }, "AdminsTable" - ).withMapper( + ).withMapper( keyFromToTo = { chatId }, valueFromToTo = { ExposedBlob(serializationFormat.encodeToByteArray(this)) }, keyToToFrom = { toChatId() }, @@ -38,19 +41,21 @@ fun AdminsCacheAPI( { long("chatId") }, { long("datetime") }, "AdminsUpdatesTimesTable" - ).withMapper( + ).withMapper( keyFromToTo = { chatId }, - keyToToFrom = { toChatId() } + valueFromToTo = { this }, + keyToToFrom = { toChatId() }, + valueToToFrom = { this } ), scope ), - settingsAPI: AdminsCacheSettingsAPI = DynamicAdminsCacheSettingsAPI( + DynamicAdminsCacheSettingsAPI( ExposedKeyValueRepo( database, { long("chatId") }, { blob("settings") }, "DynamicAdminsCacheSettingsAPI" - ).withMapper( + ).withMapper( keyFromToTo = { chatId }, valueFromToTo = { ExposedBlob(serializationFormat.encodeToByteArray(this)) }, keyToToFrom = { toChatId() }, @@ -58,10 +63,6 @@ fun AdminsCacheAPI( ), scope ) -) : AdminsCacheAPI = DefaultAdminsCacheAPI( - bot, - repo, - settingsAPI ) fun BehaviourContext.AdminsCacheAPI(database: Database) = AdminsCacheAPI(this, database, this) diff --git a/extensions.gradle b/extensions.gradle index 0c108ed..f686575 100644 --- a/extensions.gradle +++ b/extensions.gradle @@ -19,6 +19,6 @@ allprojects { defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle" - // publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle" + publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle" } } diff --git a/mppAndroidProject.gradle b/mppAndroidProject.gradle index af688ee..7896635 100644 --- a/mppAndroidProject.gradle +++ b/mppAndroidProject.gradle @@ -1,7 +1,7 @@ project.version = "$version" project.group = "$group" -// apply from: "$publishGradlePath" +apply from: "$publishGradlePath" kotlin { android { diff --git a/mppJavaProject.gradle b/mppJavaProject.gradle index aa9cc2c..c2b2f52 100644 --- a/mppJavaProject.gradle +++ b/mppJavaProject.gradle @@ -1,7 +1,7 @@ project.version = "$version" project.group = "$group" -// apply from: "$publishGradlePath" +apply from: "$publishGradlePath" kotlin { jvm { diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle index 26e5929..3806b6f 100644 --- a/mppProjectWithSerialization.gradle +++ b/mppProjectWithSerialization.gradle @@ -1,7 +1,7 @@ project.version = "$version" project.group = "$group" -// apply from: "$publishGradlePath" +apply from: "$publishGradlePath" kotlin { jvm { diff --git a/publish.gradle b/publish.gradle new file mode 100644 index 0000000..cbacda7 --- /dev/null +++ b/publish.gradle @@ -0,0 +1,57 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task javadocsJar(type: Jar) { + classifier = 'javadoc' +} + +publishing { + publications.all { + artifact javadocsJar + + pom { + description = "${project.name}" + name = "${project.name}" + url = "https://github.com/InsanusMokrassar/TelegramBotApiLibraries" + + scm { + developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git[push=]https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git" + url = "https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git" + } + + developers { + + developer { + id = "InsanusMokrassar" + name = "Ovsiannikov Aleksei" + email = "ovsyannikov.alexey95@gmail.com" + } + + } + + licenses { + + license { + name = "MIT License" + url = "https://opensource.org/licenses/MIT" + } + + } + } + repositories { + maven { + name = "sonatype" + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') + password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') + } + } + } + } +} + +signing { + useGpgCmd() + sign publishing.publications +} diff --git a/publish_config.kpsb b/publish_config.kpsb new file mode 100644 index 0000000..a8f5745 --- /dev/null +++ b/publish_config.kpsb @@ -0,0 +1 @@ +{"licenses":[{"id":"MIT","title":"MIT License","url":"https://opensource.org/licenses/MIT"}],"mavenConfig":{"name":"${project.name}","description":"${project.name}","url":"https://github.com/InsanusMokrassar/TelegramBotApiLibraries","vcsUrl":"https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}} \ No newline at end of file