diff --git a/exposed/build.gradle b/exposed/build.gradle deleted file mode 100644 index 6899f4079ce..00000000000 --- a/exposed/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id "org.jetbrains.kotlin.multiplatform" - id "org.jetbrains.kotlin.plugin.serialization" -} - -apply from: "$mppJavaProjectPresetPath" - -kotlin { - sourceSets { - commonMain { - dependencies { - - } - } - } -} diff --git a/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/exposed/QueryExtensions.kt b/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/exposed/QueryExtensions.kt deleted file mode 100644 index c5b9cc02ca3..00000000000 --- a/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/exposed/QueryExtensions.kt +++ /dev/null @@ -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, 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 } -) diff --git a/extensions.gradle b/extensions.gradle index 99920c3866f..f71cff3286a 100644 --- a/extensions.gradle +++ b/extensions.gradle @@ -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" } } diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/PaginationInUrl.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/PaginationInUrl.kt deleted file mode 100644 index 9bb00c623ea..00000000000 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/PaginationInUrl.kt +++ /dev/null @@ -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 - ) diff --git a/maven.publish.gradle b/maven.publish.gradle new file mode 100644 index 00000000000..baea6c79538 --- /dev/null +++ b/maven.publish.gradle @@ -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" + } + + } + } + } +} \ No newline at end of file diff --git a/mppJavaProject b/mppJavaProject index b739112570f..fc03ee1543c 100644 --- a/mppJavaProject +++ b/mppJavaProject @@ -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 { diff --git a/mppProjectWithSerialization b/mppProjectWithSerialization index 41993c06c19..dc6a1237535 100644 --- a/mppProjectWithSerialization +++ b/mppProjectWithSerialization @@ -1,6 +1,8 @@ project.version = "$version" project.group = "$group" +apply from: "$publishGradlePath" + repositories { jcenter() mavenCentral() diff --git a/pagination/exposed/build.gradle b/pagination/exposed/build.gradle index b3c9b47e4cb..e89fe5afe6d 100644 --- a/pagination/exposed/build.gradle +++ b/pagination/exposed/build.gradle @@ -12,5 +12,10 @@ kotlin { api internalProject("micro_utils.pagination.common") } } + jvmMain { + dependencies { + api "org.jetbrains.exposed:exposed-core:$kotlin_exposed_version" + } + } } } diff --git a/pubconf.kpsb b/pubconf.kpsb new file mode 100644 index 00000000000..144d028af55 --- /dev/null +++ b/pubconf.kpsb @@ -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"} \ No newline at end of file diff --git a/publish.gradle b/publish.gradle new file mode 100644 index 00000000000..076e4e4548c --- /dev/null +++ b/publish.gradle @@ -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 \ No newline at end of file diff --git a/repos/exposed/build.gradle b/repos/exposed/build.gradle index b4a3d77c1f4..a9382eaa414 100644 --- a/repos/exposed/build.gradle +++ b/repos/exposed/build.gradle @@ -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") } } } diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedReadCRUDRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedReadCRUDRepo.kt index 5ebd0b33847..af9e7c268e4 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedReadCRUDRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/AbstractExposedReadCRUDRepo.kt @@ -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 diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt index 8e556fdf0bf..83ca592d8ee 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt @@ -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 diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt index 37b0bb763f0..72ccc7ae84f 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/onetomany/AbstractOneToManyExposedReadKeyValueRepo.kt @@ -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 diff --git a/settings.gradle b/settings.gradle index 9acb121ff06..333d1080497 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,8 +15,7 @@ String[] includes = [ ":ktor:server", ":ktor:common", ":ktor:client", - ":coroutines", - ":exposed" + ":coroutines" ]