This commit is contained in:
InsanusMokrassar 2020-09-27 20:25:42 +06:00
parent 4fd5096829
commit 56e6dfac9f
15 changed files with 136 additions and 75 deletions

View File

@ -1,16 +0,0 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
}
apply from: "$mppJavaProjectPresetPath"
kotlin {
sourceSets {
commonMain {
dependencies {
}
}
}
}

View File

@ -1,27 +0,0 @@
package dev.inmo.micro_utils.exposed
import dev.inmo.micro_utils.pagination.*
import org.jetbrains.exposed.sql.*
fun Query.paginate(with: Pagination, orderBy: Pair<Expression<*>, SortOrder>? = null) = limit(
with.size,
(if (orderBy ?.second == SortOrder.DESC) {
with.lastIndex
} else {
with.firstIndex
}).toLong()
).let {
if (orderBy != null) {
it.orderBy(
orderBy.first,
orderBy.second
)
} else {
it
}
}
fun Query.paginate(with: Pagination, orderBy: Expression<*>?, reversed: Boolean = false) = paginate(
with,
orderBy ?.let { it to if (reversed) SortOrder.DESC else SortOrder.ASC }
)

View File

@ -21,5 +21,8 @@ allprojects {
mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization"
mppJavaProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJavaProject"
publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle"
publishMavenPath = "${rootProject.projectDir.absolutePath}/maven.publish.gradle"
}
}

View File

@ -1,10 +0,0 @@
package dev.inmo.micro_utils.ktor.server
import dev.inmo.micro_utils.pagination.*
import io.ktor.http.Parameters
val Parameters.extractPagination: Pagination
get() = SimplePagination(
get("page") ?.toIntOrNull() ?: 0,
get("size") ?.toIntOrNull() ?: defaultMediumPageSize
)

60
maven.publish.gradle Normal file
View File

@ -0,0 +1,60 @@
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 = ""
name = "${project.name}"
url = "https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror"
scm {
developerConnection = "scm:git:[fetch=]ssh://git@git.inmo.dev:8322/InsanusMokrassar/MicroUtils_mirror.git[push=]ssh://git@git.inmo.dev:8322/InsanusMokrassar/MicroUtils_mirror.git"
url = "ssh://git@git.inmo.dev:8322/InsanusMokrassar/MicroUtils_mirror.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Aleksei Ovsiannikov"
email = "ovsyannikov.alexey95@gmail.com"
}
developer {
id = "000Sanya"
name = "Syrov Aleksandr"
email = "000sanya.000sanya@gmail.com"
}
}
licenses {
license {
name = "Apache Software License 2.0"
url = "https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror/src/master/LICENSE"
}
}
}
}
}

View File

@ -1,6 +1,8 @@
project.version = "$version"
project.group = "$group"
apply from: "$publishGradlePath"
repositories {
mavenLocal()
jcenter()
@ -15,8 +17,6 @@ kotlin {
commonMain {
dependencies {
implementation kotlin('stdlib')
api internalProject("micro_utils.pagination.common")
}
}
commonTest {
@ -28,7 +28,6 @@ kotlin {
jvmMain {
dependencies {
api "org.jetbrains.exposed:exposed-core:$kotlin_exposed_version"
}
}
jvmTest {

View File

@ -1,6 +1,8 @@
project.version = "$version"
project.group = "$group"
apply from: "$publishGradlePath"
repositories {
jcenter()
mavenCentral()

View File

@ -12,5 +12,10 @@ kotlin {
api internalProject("micro_utils.pagination.common")
}
}
jvmMain {
dependencies {
api "org.jetbrains.exposed:exposed-core:$kotlin_exposed_version"
}
}
}
}

1
pubconf.kpsb Normal file
View File

@ -0,0 +1 @@
{"bintrayConfig":{"repo":"MicroUtils","packageName":"${project.name}","packageVcs":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror","autoPublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror/src/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"","url":"https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror","vcsUrl":"ssh://git@git.inmo.dev:8322/InsanusMokrassar/MicroUtils_mirror.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}]},"type":"Multiplatform"}

58
publish.gradle Normal file
View File

@ -0,0 +1,58 @@
apply plugin: 'com.jfrog.bintray'
apply from: "$publishMavenPath"
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(".", "/")
}
publish = true
pkg {
repo = "MicroUtils"
name = "${project.name}"
vcsUrl = "https://git.inmo.dev/InsanusMokrassar/MicroUtils_mirror"
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

@ -10,11 +10,7 @@ kotlin {
commonMain {
dependencies {
api internalProject("micro_utils.repos.common")
}
}
jvmMain {
dependencies {
api internalProject("micro_utils.exposed")
api internalProject("micro_utils.pagination.exposed")
}
}
}

View File

@ -1,9 +1,6 @@
package dev.inmo.micro_utils.repos.exposed
import dev.inmo.micro_utils.exposed.paginate
import dev.inmo.micro_utils.pagination.Pagination
import dev.inmo.micro_utils.pagination.PaginationResult
import dev.inmo.micro_utils.pagination.createPaginationResult
import dev.inmo.micro_utils.pagination.*
import dev.inmo.micro_utils.repos.ReadStandardCRUDRepo
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction

View File

@ -1,9 +1,6 @@
package dev.inmo.micro_utils.repos.exposed.keyvalue
import dev.inmo.micro_utils.exposed.paginate
import dev.inmo.micro_utils.pagination.Pagination
import dev.inmo.micro_utils.pagination.PaginationResult
import dev.inmo.micro_utils.pagination.createPaginationResult
import dev.inmo.micro_utils.pagination.*
import dev.inmo.micro_utils.repos.StandardReadKeyValueRepo
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction

View File

@ -1,9 +1,6 @@
package dev.inmo.micro_utils.repos.exposed.onetomany
import dev.inmo.micro_utils.exposed.paginate
import dev.inmo.micro_utils.pagination.Pagination
import dev.inmo.micro_utils.pagination.PaginationResult
import dev.inmo.micro_utils.pagination.createPaginationResult
import dev.inmo.micro_utils.pagination.*
import dev.inmo.micro_utils.repos.OneToManyReadKeyValueRepo
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction

View File

@ -15,8 +15,7 @@ String[] includes = [
":ktor:server",
":ktor:common",
":ktor:client",
":coroutines",
":exposed"
":coroutines"
]