add websockets work
This commit is contained in:
core
api
ktor
client
src
commonMain
kotlin
com
insanusmokrassar
postssystem
core
common
src
commonMain
kotlin
com
insanusmokrassar
postssystem
core
ktor
ktor
client
common
server
build.gradlemaven.publish.gradlepublish.gradlepublish_config.kpsb
src
jvmMain
kotlin
com
insanusmokrassar
postssystem
ktor
tests
utils
common
build.gradlemaven.publish.gradlepublish.gradlepublish_config.json
src
commonMain
kotlin
com
insanusmokrassar
postssystem
repos
common
79
utils/common/build.gradle
Normal file
79
utils/common/build.gradle
Normal file
@ -0,0 +1,79 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||
}
|
||||
|
||||
project.version = "$core_version"
|
||||
project.group = "com.insanusmokrassar"
|
||||
|
||||
apply from: "publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
||||
|
||||
api "com.soywiz.korlibs.klock:klock:$klockVersion"
|
||||
api "com.benasher44:uuid:$uuidVersion"
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-jdk8')
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-js')
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-js')
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
utils/common/maven.publish.gradle
Normal file
64
utils/common/maven.publish.gradle
Normal file
@ -0,0 +1,64 @@
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
task javadocsJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
project.publishing.publications.all {
|
||||
// rename artifacts
|
||||
groupId "${project.group}"
|
||||
if (it.name.contains('kotlinMultiplatform')) {
|
||||
artifactId = "${project.name}"
|
||||
} else {
|
||||
artifactId = "${project.name}-$name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications.all {
|
||||
artifact javadocsJar
|
||||
|
||||
pom.withXml {
|
||||
asNode().children().last() + {
|
||||
resolveStrategy = Closure.DELEGATE_FIRST
|
||||
|
||||
description "Core library for PostsSystem"
|
||||
name "PostsSystem Core"
|
||||
url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore"
|
||||
|
||||
scm {
|
||||
developerConnection "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git[push=]https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git"
|
||||
url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git"
|
||||
}
|
||||
|
||||
developers {
|
||||
|
||||
developer {
|
||||
id "InsanusMokrassar"
|
||||
name "Ovsiannikov Aleksei"
|
||||
email "ovsyannikov.alexey95@gmail.com"
|
||||
}
|
||||
|
||||
|
||||
developer {
|
||||
id "mi-ast"
|
||||
name "Michail Astafiev"
|
||||
email "astaf65@gmail.com"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
licenses {
|
||||
|
||||
license {
|
||||
name "Apache Software License 2.0"
|
||||
url "https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
55
utils/common/publish.gradle
Normal file
55
utils/common/publish.gradle
Normal file
@ -0,0 +1,55 @@
|
||||
apply plugin: 'com.jfrog.bintray'
|
||||
|
||||
apply from: "maven.publish.gradle"
|
||||
|
||||
bintray {
|
||||
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
||||
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
||||
filesSpec {
|
||||
from "${buildDir}/publications/"
|
||||
eachFile {
|
||||
String directorySubname = it.getFile().parentFile.name
|
||||
if (it.getName() == "module.json") {
|
||||
if (directorySubname == "kotlinMultiplatform") {
|
||||
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
|
||||
} else {
|
||||
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
|
||||
}
|
||||
} else {
|
||||
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
|
||||
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
|
||||
} else {
|
||||
it.exclude()
|
||||
}
|
||||
}
|
||||
}
|
||||
into "${project.group}".replace(".", "/")
|
||||
}
|
||||
pkg {
|
||||
repo = "InsanusMokrassar"
|
||||
name = "${project.name}"
|
||||
vcsUrl = "https://github.com/PostsSystem/PostsSystemCore"
|
||||
licenses = ["Apache-2.0"]
|
||||
version {
|
||||
name = "${project.version}"
|
||||
released = new Date()
|
||||
vcsTag = "${project.version}"
|
||||
gpg {
|
||||
sign = true
|
||||
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bintrayUpload.doFirst {
|
||||
publications = publishing.publications.collect {
|
||||
if (it.name.contains('kotlinMultiplatform')) {
|
||||
null
|
||||
} else {
|
||||
it.name
|
||||
}
|
||||
} - null
|
||||
}
|
||||
|
||||
bintrayUpload.dependsOn publishToMavenLocal
|
1
utils/common/publish_config.json
Normal file
1
utils/common/publish_config.json
Normal file
@ -0,0 +1 @@
|
||||
{"bintrayConfig":{"repo":"InsanusMokrassar","packageName":"${project.name}","packageVcs":"https://github.com/PostsSystem/PostsSystemCore"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core","description":"Core library for PostsSystem","url":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/PostsSystemCore.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"mi-ast","name":"Michail Astafiev","eMail":"astaf65@gmail.com"}]}}
|
20
utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/ByteArrayAllocator.kt
Normal file
20
utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/ByteArrayAllocator.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package com.insanusmokrassar.postssystem.utils.common
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ByteArraySerializer
|
||||
|
||||
typealias ByteArrayAllocator = () -> ByteArray
|
||||
|
||||
object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator> {
|
||||
private val realSerializer = ByteArraySerializer()
|
||||
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): ByteArrayAllocator {
|
||||
val bytes = decoder.decode(realSerializer)
|
||||
return { bytes }
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: ByteArrayAllocator) {
|
||||
encoder.encodeSerializableValue(realSerializer, value())
|
||||
}
|
||||
}
|
6
utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/DateTimeUtils.kt
Normal file
6
utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/DateTimeUtils.kt
Normal file
@ -0,0 +1,6 @@
|
||||
package com.insanusmokrassar.postssystem.utils.common
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
|
||||
val MIN_DATE = DateTime(0)
|
||||
val MAX_DATE = DateTime(Long.MAX_VALUE)
|
23
utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/HandleSafely.kt
Normal file
23
utils/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/utils/common/HandleSafely.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package com.insanusmokrassar.postssystem.utils.common
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
|
||||
|
||||
typealias ExceptionHandler<T> = suspend (Throwable) -> T
|
||||
/**
|
||||
* It will run [block] inside of [supervisorScope] to avoid problems with catching of exceptions
|
||||
*
|
||||
* @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this
|
||||
* exception will be available for catching
|
||||
*/
|
||||
suspend inline fun <T> safely(
|
||||
noinline onException: ExceptionHandler<T> = { throw it },
|
||||
noinline block: suspend CoroutineScope.() -> T
|
||||
): T {
|
||||
return try {
|
||||
supervisorScope(block)
|
||||
} catch (e: Throwable) {
|
||||
onException(e)
|
||||
}
|
||||
}
|
@ -37,11 +37,8 @@ kotlin {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
||||
|
||||
api "com.soywiz.korlibs.klock:klock:$klockVersion"
|
||||
api "com.benasher44:uuid:$uuidVersion"
|
||||
api projectByName("postssystem.utils.common")
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
|
Reference in New Issue
Block a user