add projectByName function

This commit is contained in:
InsanusMokrassar 2020-08-10 19:09:46 +06:00
parent 8bd6ef3d5f
commit 14a40bfef0
25 changed files with 95 additions and 57 deletions

View File

@ -13,6 +13,15 @@ repositories {
maven { url "https://kotlin.bintray.com/kotlinx" }
}
subprojects.each {
println(it)
allprojects {
ext {
projectByName = { name ->
for (subproject in rootProject.subprojects) {
if (subproject.name == name) {
return subproject
}
}
return null
}
}
}

View File

@ -41,7 +41,7 @@ kotlin {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.utils.repos:$core_version"
} else {
api project(":utils:repos:postssystem.utils.repos.common")
api projectByName("postssystem.utils.repos.common")
}
}
}

View File

@ -37,8 +37,8 @@ dependencies {
api "com.insanusmokrassar:postssystem.core.api:$core_version"
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
} else {
api project(":core:postssystem.core.api")
api project(":exposed:postssystem.exposed.commons")
api projectByName("postssystem.core.api")
api projectByName("postssystem.exposed.commons")
}
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"

View File

@ -42,8 +42,8 @@ kotlin {
api "com.insanusmokrassar:postssystem.core.ktor.common:$core_version"
api "com.insanusmokrassar:postssystem.ktor.client:$core_version"
} else {
api project(":core:ktor:postssystem.core.ktor.common")
api project(":ktor:postssystem.ktor.client")
api projectByName("postssystem.core.ktor.common")
api projectByName("postssystem.ktor.client")
}
}
}

View File

@ -1,32 +1,35 @@
package com.insanusmokrassar.postssystem.core.ktor.client.content
//import com.insanusmokrassar.postssystem.core.content.ContentId
//import com.insanusmokrassar.postssystem.core.content.RegisteredContent
//import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo
//import com.insanusmokrassar.postssystem.core.ktor.getContentByIdRoute
//import com.insanusmokrassar.postssystem.core.ktor.getContentsIdsRoute
//import com.insanusmokrassar.postssystem.utils.repos.pagination.Pagination
//import com.insanusmokrassar.postssystem.utils.repos.pagination.PaginationResult
//import io.ktor.client.HttpClient
//import io.ktor.client.request.get
//import io.ktor.client.statement.HttpResponse
//import kotlinx.io.InputStream
//
//class ReadContentRepoKtorClient(
// private val client: HttpClient,
// private val baseUrl: String
//) : ReadContentRepo {
// override suspend fun getContentsIds(): Set<ContentId> = client.get<HttpResponse>(
// "$baseUrl/$getContentsIdsRoute"
// ).content.let {
// TODO()
// }
//
// override suspend fun getContentById(id: ContentId): RegisteredContent? {
// TODO("Not yet implemented")
// }
//
// override suspend fun getContentByPagination(pagination: Pagination): PaginationResult<out RegisteredContent> {
// TODO("Not yet implemented")
// }
//}
import com.insanusmokrassar.postssystem.core.content.ContentId
import com.insanusmokrassar.postssystem.core.content.RegisteredContent
import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo
import com.insanusmokrassar.postssystem.core.ktor.*
import com.insanusmokrassar.postssystem.ktor.standardKtorSerializer
import com.insanusmokrassar.postssystem.utils.repos.pagination.Pagination
import com.insanusmokrassar.postssystem.utils.repos.pagination.PaginationResult
import io.ktor.client.HttpClient
import io.ktor.client.request.get
import kotlinx.serialization.builtins.nullable
class ReadContentRepoKtorClient(
private val client: HttpClient,
private val baseUrl: String
) : ReadContentRepo {
override suspend fun getContentsIds(): Set<ContentId> = client.get<ByteArray>(
"$baseUrl/$getContentsIdsRoute"
).let {
standardKtorSerializer.load(contentIdsSerializer, it)
}
override suspend fun getContentById(id: ContentId): RegisteredContent? = client.get<ByteArray>(
"$baseUrl/$getContentByIdRoute"
).let {
standardKtorSerializer.load(RegisteredContent.serializer().nullable, it)
}
override suspend fun getContentByPagination(pagination: Pagination): PaginationResult<out RegisteredContent> = client.get<ByteArray>(
"$baseUrl/$getContentByPaginationRoute"
).let {
standardKtorSerializer.load(registeredContentPaginationResultSerializer, it)
}
}

View File

@ -0,0 +1,15 @@
package com.insanusmokrassar.postssystem.core.ktor.client.content
import com.insanusmokrassar.postssystem.core.content.*
import com.insanusmokrassar.postssystem.core.content.api.WriteContentRepo
class WriteContentRepoKtorClient : WriteContentRepo {
override suspend fun registerContent(content: Content): RegisteredContent? {
TODO("Not yet implemented")
}
override suspend fun deleteContent(id: ContentId): Boolean {
TODO("Not yet implemented")
}
}

View File

@ -42,8 +42,8 @@ kotlin {
api "com.insanusmokrassar:postssystem.ktor.common:$core_version"
api "com.insanusmokrassar:postssystem.core.api:$core_version"
} else {
api project(":ktor:postssystem.ktor.common")
api project(":core:postssystem.core.api")
api projectByName("postssystem.ktor.common")
api projectByName("postssystem.core.api")
}
}
}

View File

@ -3,3 +3,6 @@ package com.insanusmokrassar.postssystem.core.ktor
const val getContentsIdsRoute = "getContentsIds"
const val getContentByIdRoute = "getContentById"
const val getContentByPaginationRoute = "getContentByPagination"
const val registerContentRoute = "registerContent"
const val deleteContentRoute = "deleteContent"

View File

@ -0,0 +1,8 @@
package com.insanusmokrassar.postssystem.core.ktor
import com.insanusmokrassar.postssystem.core.content.RegisteredContent
import com.insanusmokrassar.postssystem.ktor.setIdsSerializer
import com.insanusmokrassar.postssystem.utils.repos.pagination.PaginationResult
val contentIdsSerializer = setIdsSerializer
val registeredContentPaginationResultSerializer = PaginationResult.serializer(RegisteredContent.serializer())

View File

@ -38,7 +38,7 @@ dependencies {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.utils.repos:$core_version"
} else {
api project(":utils:repos:postssystem.utils.repos.common")
api projectByName("postssystem.utils.repos.common")
}
testImplementation "org.jetbrains.kotlin:kotlin-test"

View File

@ -41,7 +41,7 @@ kotlin {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.ktor.common:$core_version"
} else {
api project(":ktor:postssystem.ktor.common")
api projectByName("postssystem.ktor.common")
}
api "io.ktor:ktor-client-core:$ktor_version"

View File

@ -0,0 +1,6 @@
package com.insanusmokrassar.postssystem.ktor
import kotlinx.serialization.builtins.SetSerializer
import kotlinx.serialization.builtins.serializer
val setIdsSerializer = SetSerializer(String.serializer())

View File

@ -43,7 +43,7 @@ kotlin {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core.api:$core_version"
} else {
api project(":core:postssystem.core.api")
api projectByName("postssystem.core.api")
}
api "com.soywiz.korlibs.klock:klock:$klockVersion"

View File

@ -13,8 +13,8 @@ buildscript {
}
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
}
project.version = "$core_version"
@ -43,7 +43,7 @@ kotlin {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.markups.core:$core_version"
} else {
api project(":markups")
api projectByName("postssystem.markups.commons")
}
}
}

View File

@ -41,7 +41,7 @@ kotlin {
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core.api:$core_version"
} else {
api project(":core:postssystem.core.api")
api projectByName("postssystem.core.api")
}
}
}

View File

@ -37,8 +37,8 @@ dependencies {
api "com.insanusmokrassar:postssystem.core.publishing:$core_version"
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
} else {
api project(":publishing:postssystem.publishing.api")
api project(":exposed:postssystem.exposed.commons")
api projectByName("postssystem.publishing.api")
api projectByName("postssystem.exposed.commons")
}
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"

View File

@ -1,30 +1,25 @@
rootProject.name='postssystem'
String[] includes = [
':utils',
':utils:repos',
':utils:repos:common',
':utils:repos:exposed',
':exposed',
':exposed:commons',
':ktor',
':ktor:common',
':ktor:client',
':core',
':core:api',
':core:exposed',
':core:ktor',
':core:ktor:common',
':core:ktor:client',
':publishing',
':publishing:api',
':publishing:exposed',
':markups',
':markups:commons',
':markups:html'
]
@ -32,6 +27,5 @@ String[] includes = [
includes.each {
include it
ProjectDescriptor project = project(it)
println(project.projectDir.absolutePath.replace(rootDir.absolutePath, ""))
project.name = rootProject.name + project.projectDir.absolutePath.replace(rootDir.absolutePath, "").replace("/", ".")
}

View File

@ -37,8 +37,8 @@ dependencies {
api "com.insanusmokrassar:postssystem.utils.repos:$core_version"
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
} else {
api project(":utils:repos:postssystem.utils.repos.common")
api project(":exposed:postssystem.exposed.commons")
api projectByName("postssystem.utils.repos.common")
api projectByName("postssystem.exposed.commons")
}
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"