From d5e1d18378ae880033e8e92f2dd51a44770ceba2 Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Sat, 18 Sep 2021 00:25:31 +0300 Subject: [PATCH] Hotfixing the module file of ktoml-file in build.gradle --- detekt.yml | 16 ++++++++++ ktoml-core/build.gradle.kts | 11 ++----- ktoml-file/build.gradle.kts | 31 +++++++++++-------- .../akuleshov7/ktoml/file/FileUtilsLin.kt} | 0 .../com/akuleshov7/ktoml/file/FileUtilsMac.kt | 14 +++++++++ .../com/akuleshov7/ktoml/file/FileUtilsWin.kt | 14 +++++++++ 6 files changed, 65 insertions(+), 21 deletions(-) rename ktoml-file/src/{nativeMain/kotlin/com/akuleshov7/ktoml/file/FileUtilsNative.kt => linuxX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsLin.kt} (100%) create mode 100644 ktoml-file/src/macosX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMac.kt create mode 100644 ktoml-file/src/mingwX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsWin.kt diff --git a/detekt.yml b/detekt.yml index 5ad30673..e56e6031 100644 --- a/detekt.yml +++ b/detekt.yml @@ -2,3 +2,19 @@ potential-bugs: Deprecation: active: true + +formatting: + MaximumLineLength: + active: false + maxLineLength: 180 + +style: + MaxLineLength: + active: true + maxLineLength: 180 + # wildcards are used all over the project + WildcardImport: + active: false + # code is not stable yet, TODOs are still needed + ForbiddenComment: + active: false \ No newline at end of file diff --git a/ktoml-core/build.gradle.kts b/ktoml-core/build.gradle.kts index e3853b22..59d344e7 100644 --- a/ktoml-core/build.gradle.kts +++ b/ktoml-core/build.gradle.kts @@ -25,14 +25,9 @@ kotlin { } } - val os = getCurrentOperatingSystem() - - when { - os.isWindows -> mingwX64() - os.isLinux -> linuxX64() - os.isMacOsX -> macosX64() - else -> throw GradleException("Unknown operating system $os") - } + mingwX64() + linuxX64() + macosX64() sourceSets { all { diff --git a/ktoml-file/build.gradle.kts b/ktoml-file/build.gradle.kts index 8f705fb4..587c61b5 100644 --- a/ktoml-file/build.gradle.kts +++ b/ktoml-file/build.gradle.kts @@ -18,21 +18,30 @@ kotlin { } } - val os = getCurrentOperatingSystem() - - val target = listOf(when { - os.isWindows -> mingwX64() - os.isLinux -> linuxX64() - os.isMacOsX -> macosX64() - else -> throw GradleException("Unknown operating system $os") - }) + mingwX64() + linuxX64() + macosX64() sourceSets { all { languageSettings.optIn("kotlin.RequiresOptIn") } - val nativeMain by creating { + val linuxX64Main by getting { + dependencies { + implementation("com.squareup.okio:okio:${Versions.OKIO}") + implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN}") + } + } + + val mingwX64Main by getting { + dependencies { + implementation("com.squareup.okio:okio:${Versions.OKIO}") + implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN}") + } + } + + val macosX64Main by getting { dependencies { implementation("com.squareup.okio:okio:${Versions.OKIO}") implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN}") @@ -54,10 +63,6 @@ kotlin { } } - target.forEach { - getByName("${it.name}Main").dependsOn(nativeMain) - } - val commonTest by getting { dependencies { implementation(kotlin("test-common")) diff --git a/ktoml-file/src/nativeMain/kotlin/com/akuleshov7/ktoml/file/FileUtilsNative.kt b/ktoml-file/src/linuxX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsLin.kt similarity index 100% rename from ktoml-file/src/nativeMain/kotlin/com/akuleshov7/ktoml/file/FileUtilsNative.kt rename to ktoml-file/src/linuxX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsLin.kt diff --git a/ktoml-file/src/macosX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMac.kt b/ktoml-file/src/macosX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMac.kt new file mode 100644 index 00000000..6904d387 --- /dev/null +++ b/ktoml-file/src/macosX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMac.kt @@ -0,0 +1,14 @@ +/** + * File utils to read files using okio + */ + +package com.akuleshov7.ktoml.file + +import okio.FileSystem + +/** + * Implementation for getting proper file system to read files with okio + * + * @return proper FileSystem + */ +internal actual fun getOsSpecificFileSystem(): FileSystem = FileSystem.SYSTEM diff --git a/ktoml-file/src/mingwX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsWin.kt b/ktoml-file/src/mingwX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsWin.kt new file mode 100644 index 00000000..6904d387 --- /dev/null +++ b/ktoml-file/src/mingwX64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsWin.kt @@ -0,0 +1,14 @@ +/** + * File utils to read files using okio + */ + +package com.akuleshov7.ktoml.file + +import okio.FileSystem + +/** + * Implementation for getting proper file system to read files with okio + * + * @return proper FileSystem + */ +internal actual fun getOsSpecificFileSystem(): FileSystem = FileSystem.SYSTEM