just commit
This commit is contained in:
47
postssystem.core.publishing.exposed/build.gradle
Normal file
47
postssystem.core.publishing.exposed/build.gradle
Normal file
@@ -0,0 +1,47 @@
|
||||
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 {
|
||||
implementation "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.publishing:$core_version"
|
||||
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
|
||||
} else {
|
||||
api project(":postssystem.core.publishing")
|
||||
api project(":postssystem.exposed.commons")
|
||||
}
|
||||
|
||||
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
||||
}
|
2
postssystem.core.publishing.exposed/gradle.properties
Normal file
2
postssystem.core.publishing.exposed/gradle.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
exposed_version=0.23.1
|
||||
test_sqlite_version=3.28.0
|
53
postssystem.core.publishing.exposed/maven.publish.gradle
Normal file
53
postssystem.core.publishing.exposed/maven.publish.gradle
Normal 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 = "Exposed realisation for PostsSystem Core Publishing subsystem"
|
||||
name = "PostsSystem Core Publishing Exposed realization"
|
||||
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"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
55
postssystem.core.publishing.exposed/publish.gradle
Normal file
55
postssystem.core.publishing.exposed/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
postssystem.core.publishing.exposed/publish_config.kpsb
Normal file
1
postssystem.core.publishing.exposed/publish_config.kpsb
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/Core/src/master/LICENSE"}],"mavenConfig":{"name":"PostsSystem Core Publishing Exposed realization","description":"Exposed realisation for PostsSystem Core Publishing subsystem","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"}
|
@@ -0,0 +1,56 @@
|
||||
package com.insanusmokrassar.postssystem.core.publishing.exposed
|
||||
|
||||
import com.insanusmokrassar.postssystem.core.post.PostId
|
||||
import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey
|
||||
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
class ExposedPublishingKeysRepo(
|
||||
private val database: Database
|
||||
) : PublishingKeysRepo, Table() {
|
||||
private val postIdColumn: Column<PostId> = text("postId")
|
||||
private val triggerControlKeyColumn: Column<PostId> = text("triggerControlKey")
|
||||
override val primaryKey: PrimaryKey = PrimaryKey(postIdColumn, triggerControlKeyColumn)
|
||||
|
||||
init {
|
||||
transaction(database) {
|
||||
SchemaUtils.createMissingTablesAndColumns(this@ExposedPublishingKeysRepo)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = newSuspendedTransaction(
|
||||
db = database
|
||||
) {
|
||||
select { triggerControlKeyColumn.eq(key) }.limit(1).firstOrNull() ?.getOrNull(postIdColumn)
|
||||
}
|
||||
|
||||
override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = newSuspendedTransaction(
|
||||
db = database
|
||||
) {
|
||||
select { postIdColumn.eq(postId) }.limit(1).firstOrNull() ?.getOrNull(triggerControlKeyColumn)
|
||||
}
|
||||
|
||||
override suspend fun setPostTriggerControlKey(postId: PostId, key: TriggerControlKey): Boolean = newSuspendedTransaction(
|
||||
db = database
|
||||
) {
|
||||
unsetPostTriggerControlKey(postId)
|
||||
insert {
|
||||
it[postIdColumn] = postId
|
||||
it[triggerControlKeyColumn] = triggerControlKeyColumn
|
||||
}.getOrNull(postIdColumn) == postId
|
||||
}
|
||||
|
||||
override suspend fun unsetPostTriggerControlKey(postId: PostId): Boolean = newSuspendedTransaction(
|
||||
db = database
|
||||
) {
|
||||
deleteWhere {
|
||||
postIdColumn.eq(postId)
|
||||
} > 0
|
||||
}
|
||||
}
|
||||
|
||||
class DatabasePublishingKeysRepo(
|
||||
database: Database
|
||||
): PublishingKeysRepo by ExposedPublishingKeysRepo(database)
|
Reference in New Issue
Block a user