From 9b48cc9214b0a914a7459548786c48c580aab94a Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Apr 2020 16:30:20 +0600 Subject: [PATCH] fixes in exposed --- postssystem.exposed/build.gradle | 55 +++++-------------- postssystem.exposed/gradle.properties | 2 +- postssystem.exposed/publish_config.json | 2 +- .../postssystem/core/exposed/ChannelsSizes.kt | 0 .../core/exposed/ExposedContentAPI.kt | 0 .../core/exposed/ExposedPostsAPI.kt | 0 .../core/exposed/QueryExtensions.kt | 0 .../exposed/ExposedContentAPICommonTests.kt | 4 +- .../exposed/ExposedPostsAPICommonTests.kt | 15 ++--- 9 files changed, 25 insertions(+), 53 deletions(-) rename postssystem.exposed/src/{commonMain => main}/kotlin/com/insanusmokrassar/postssystem/core/exposed/ChannelsSizes.kt (100%) rename postssystem.exposed/src/{commonMain => main}/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt (100%) rename postssystem.exposed/src/{commonMain => main}/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt (100%) rename postssystem.exposed/src/{commonMain => main}/kotlin/com/insanusmokrassar/postssystem/core/exposed/QueryExtensions.kt (100%) rename postssystem.exposed/src/{commonTest => test}/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt (98%) rename postssystem.exposed/src/{commonTest => test}/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt (83%) diff --git a/postssystem.exposed/build.gradle b/postssystem.exposed/build.gradle index 7e510dbf..44e05b27 100644 --- a/postssystem.exposed/build.gradle +++ b/postssystem.exposed/build.gradle @@ -13,14 +13,14 @@ buildscript { } plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" } project.version = "$core_version" project.group = "com.insanusmokrassar" -apply from: "publish.gradle" +apply plugin: "java-library" +apply plugin: 'kotlin' repositories { mavenLocal() @@ -29,47 +29,18 @@ repositories { maven { url "https://kotlin.bintray.com/kotlinx" } } -kotlin { - jvm() - js() +dependencies { + api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + api "org.jetbrains.exposed:exposed-core:$exposed_version" + api "org.jetbrains.exposed:exposed-jdbc:$exposed_version" - sourceSets { - commonMain { - dependencies { - implementation kotlin('stdlib') - api "org.jetbrains.exposed:exposed-core:$exposed_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") - } - } - } - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmMain { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - - jvmTest { - dependencies { - implementation kotlin('test-junit') - implementation "org.xerial:sqlite-jdbc:$test_sqlite_version" - } - } - - jsMain { - dependencies { - implementation kotlin('stdlib-js') - } - } + 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.xerial:sqlite-jdbc:$test_sqlite_version" + testImplementation "org.jetbrains.kotlin:kotlin-test" + testImplementation "org.jetbrains.kotlin:kotlin-test-junit" } diff --git a/postssystem.exposed/gradle.properties b/postssystem.exposed/gradle.properties index 2620278d..1576438d 100644 --- a/postssystem.exposed/gradle.properties +++ b/postssystem.exposed/gradle.properties @@ -1,2 +1,2 @@ exposed_version=0.23.1 -test_sqlite_version=3.30.1 +test_sqlite_version=3.28.0 diff --git a/postssystem.exposed/publish_config.json b/postssystem.exposed/publish_config.json index 7f60575f..769ff599 100644 --- a/postssystem.exposed/publish_config.json +++ b/postssystem.exposed/publish_config.json @@ -1 +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 Exposed realization","description":"Exposed realisation for PostsSystem Core","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"}]}} \ No newline at end of file +{"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 Exposed realization","description":"Exposed realisation for PostsSystem Core","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":"JVM"} \ No newline at end of file diff --git a/postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/ChannelsSizes.kt b/postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ChannelsSizes.kt similarity index 100% rename from postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/ChannelsSizes.kt rename to postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ChannelsSizes.kt diff --git a/postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt b/postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt similarity index 100% rename from postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt rename to postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt diff --git a/postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt b/postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt similarity index 100% rename from postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt rename to postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt diff --git a/postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/QueryExtensions.kt b/postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/QueryExtensions.kt similarity index 100% rename from postssystem.exposed/src/commonMain/kotlin/com/insanusmokrassar/postssystem/core/exposed/QueryExtensions.kt rename to postssystem.exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/QueryExtensions.kt diff --git a/postssystem.exposed/src/commonTest/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt b/postssystem.exposed/src/test/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt similarity index 98% rename from postssystem.exposed/src/commonTest/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt rename to postssystem.exposed/src/test/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt index 9a3ae715..23feaae8 100644 --- a/postssystem.exposed/src/commonTest/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt +++ b/postssystem.exposed/src/test/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPICommonTests.kt @@ -4,9 +4,9 @@ import com.insanusmokrassar.postssystem.core.content.SimpleTextContent import kotlinx.coroutines.runBlocking import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.transactions.transactionManager -import org.junit.jupiter.api.Test import java.io.File import java.sql.Connection +import kotlin.test.Test class ExposedContentAPICommonTests { private val tempFolder = System.getProperty("java.io.tmpdir")!! @@ -53,4 +53,4 @@ class ExposedContentAPICommonTests { File(it).delete() } } -} +} \ No newline at end of file diff --git a/postssystem.exposed/src/commonTest/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt b/postssystem.exposed/src/test/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt similarity index 83% rename from postssystem.exposed/src/commonTest/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt rename to postssystem.exposed/src/test/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt index d8e18040..45109bdb 100644 --- a/postssystem.exposed/src/commonTest/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt +++ b/postssystem.exposed/src/test/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPICommonTests.kt @@ -4,11 +4,11 @@ import com.insanusmokrassar.postssystem.core.post.SimplePost import kotlinx.coroutines.runBlocking import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.transactions.transactionManager -import org.junit.jupiter.api.* +import org.sqlite.JDBC import java.io.File import java.sql.Connection +import kotlin.test.* -@TestInstance(TestInstance.Lifecycle.PER_CLASS) class ExposedPostsAPICommonTests { private val tempFolder = System.getProperty("java.io.tmpdir")!! @@ -16,16 +16,17 @@ class ExposedPostsAPICommonTests { private lateinit var databaseFiles: List private lateinit var apis: List - @BeforeAll + @BeforeTest fun prepare() { databaseFiles = (0 until numberOfDatabases).map { File("$tempFolder/ExposedPostsAPICommonTestsDB$it.db") } apis = databaseFiles.map { + val database = Database.connect("jdbc:sqlite:${it.absolutePath}").also { + it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE + } ExposedPostsAPI( - Database.Companion.connect("jdbc:sqlite:${it.absolutePath}", driver = "org.sqlite.JDBC").also { - it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE - } + database ) } } @@ -55,7 +56,7 @@ class ExposedPostsAPICommonTests { } } - @AfterAll + @AfterTest fun `Close and delete databases`() { databaseFiles.forEach { it.delete()