start including of publishing subproject

This commit is contained in:
InsanusMokrassar 2020-07-26 23:03:23 +06:00
parent 1ef5cc5af0
commit 7cfa612a9c
24 changed files with 254 additions and 1 deletions

View File

@ -0,0 +1,44 @@
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.plugin.serialization" version "$kotlin_version"
}
project.version = "$core_version"
project.group = "com.insanusmokrassar"
apply plugin: "java-library"
apply plugin: "kotlin"
apply from: "./publish.gradle"
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core:$core_version"
} else {
implementation project(":postssystem.core")
}
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
}

View File

@ -0,0 +1,53 @@
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 {
description = "Publishing subsystem with necessary functionality related to publish mechanism"
name = "PostsSystem Core Publishing subsystem"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/"
scm {
developerConnection = "scm:git:[fetch=]https://git.insanusmokrassar.com/PostsSystem/Core/.git[push=]https://git.insanusmokrassar.com/PostsSystem/Core/.git"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Ovsiannikov Aleksei"
email = "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name = "Apache Software License 2.0"
url = "https://git.insanusmokrassar.com/PostsSystem/Core/src/master/LICENSE"
}
}
}
}
}

View 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

View 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/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Publishing subsystem","description":"Publishing subsystem with necessary functionality related to publish mechanism","url":"https://git.insanusmokrassar.com/PostsSystem/Core/","vcsUrl":"https://git.insanusmokrassar.com/PostsSystem/Core/.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}

View File

@ -0,0 +1,52 @@
package com.insanusmokrassar.postssystem.core.publishing
import com.insanusmokrassar.postssystem.core.post.PostId
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
typealias TriggerControlKey = String
interface ReadPublishingRegistrator {
suspend fun getPostIdByTriggerControlKey(
key: TriggerControlKey
): PostId?
}
interface WritePublishingRegistrator {
val unregisteredKeysFlow: Flow<TriggerControlKey>
suspend fun registerTriggerForPost(
key: TriggerControlKey,
postId: PostId
): Boolean
}
interface PublishingRegistrator : ReadPublishingRegistrator, WritePublishingRegistrator
class BusinessPublishingRegistrator(
private val repo: PublishingKeysRepo
) : PublishingRegistrator {
private val unregisteredKeysChannel: BroadcastChannel<TriggerControlKey> = BroadcastChannel(Channel.BUFFERED)
override val unregisteredKeysFlow: Flow<TriggerControlKey>
get() = TODO("Not yet implemented")
override suspend fun getPostIdByTriggerControlKey(
key: TriggerControlKey
): PostId? = repo.getPostIdByTriggerControlKey(key)
override suspend fun registerTriggerForPost(
key: TriggerControlKey,
postId: PostId
): Boolean = repo.getTriggerControlKeyByPostId(
postId
).let { previousKey ->
repo.setPostTriggerControlKey(postId, key).also { inserted ->
if (inserted && previousKey != null) {
unregisteredKeysChannel.send(previousKey)
}
}
}
}

View File

@ -0,0 +1,14 @@
package com.insanusmokrassar.postssystem.core.publishing
import com.insanusmokrassar.postssystem.core.post.PostId
import kotlinx.coroutines.flow.Flow
interface PublishingTrigger {
val postingTriggeredFlow: Flow<PostId>
suspend fun triggerPosting(
triggerControlKey: TriggerControlKey
): PostId?
}

View File

@ -0,0 +1,28 @@
package com.insanusmokrassar.postssystem.core.publishing.repos
import com.insanusmokrassar.postssystem.core.post.PostId
import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey
import kotlinx.coroutines.flow.Flow
interface ReadPublishingKeysRepo {
suspend fun getPostIdByTriggerControlKey(
key: TriggerControlKey
): PostId?
suspend fun getTriggerControlKeyByPostId(
postId: PostId
): TriggerControlKey?
}
interface WritePublishingKeysRepo {
val postTriggerControlKeyUpdated: Flow<Pair<PostId, TriggerControlKey>>
val postTriggerControlKeyUnset: Flow<PostId>
suspend fun setPostTriggerControlKey(
postId: PostId,
key: TriggerControlKey
): Boolean
suspend fun unsetPostTriggerControlKey(
postId: PostId
)
}
interface PublishingKeysRepo : ReadPublishingKeysRepo, WritePublishingKeysRepo

View File

@ -69,5 +69,10 @@ kotlin {
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
}
}
jsTest {
dependencies {
implementation kotlin('test-junit-js')
}
}
}
}

View File

@ -1,3 +1,4 @@
rootProject.name='postssystem'
include ':postssystem.core'
include ':postssystem.exposed'
include ':postssystem.core.exposed'
include ':postssystem.core.publishing'