From f1595bb5edbeeda4b12bb51687a9638132546ad3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 1 Mar 2021 20:17:06 +0600 Subject: [PATCH] rewrite on multiplatform --- .gitignore | 2 + build.gradle | 68 +++++++------------ core/build.gradle | 20 ++++++ .../core}/export/jvm_only/MavenTemplater.kt | 4 +- .../core}/export/mpp/MavenTemplater.kt | 4 +- .../kmppscriptbuilder/core}/models/Config.kt | 8 +-- .../core}/models/Developer.kt | 2 +- .../kmppscriptbuilder/core}/models/License.kt | 4 +- .../core}/models/MavenConfig.kt | 2 +- .../core}/utils/SerialFormat.kt | 2 +- core/src/main/AndroidManifest.xml | 1 + defaultAndroidSettings.gradle | 40 +++++++++++ desktop/build.gradle | 37 ++++++++++ .../kmppscriptbuilder/desktop}/Builder.kt | 6 +- .../desktop}/utils/FilesHandling.kt | 5 +- .../desktop}/utils/NewFileFilterFactory.kt | 2 +- .../desktop}/utils/UIElements.kt | 2 +- .../kmppscriptbuilder/desktop}/utils/View.kt | 2 +- .../desktop}/views/BuilderView.kt | 6 +- .../desktop}/views/DevelopersView.kt | 6 +- .../desktop}/views/LicensesView.kt | 8 +-- .../desktop}/views/ListView.kt | 5 +- .../desktop}/views/MavenInfoView.kt | 8 +-- .../desktop}/views/ProjectTypeView.kt | 6 +- .../desktop}/views/RepositoriesView.kt | 6 +- .../resources/images/export_gradle.svg | 0 .../jvmMain}/resources/images/open_file.svg | 0 .../src/jvmMain}/resources/images/save_as.svg | 0 .../jvmMain}/resources/images/save_file.svg | 0 extensions.gradle | 24 +++++++ gradle.properties | 35 ++++++++-- mppAndroidProject.gradle | 26 +++++++ mppJavaProject.gradle | 30 ++++++++ mppProjectWithSerialization.gradle | 52 ++++++++++++++ settings.gradle | 19 +++++- .../kmppscriptbuilder/models/BintrayConfig.kt | 13 ---- 36 files changed, 347 insertions(+), 108 deletions(-) create mode 100644 core/build.gradle rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/export/jvm_only/MavenTemplater.kt (94%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/export/mpp/MavenTemplater.kt (93%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/models/Config.kt (87%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/models/Developer.kt (73%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/models/License.kt (93%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/models/MavenConfig.kt (95%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core}/utils/SerialFormat.kt (64%) create mode 100644 core/src/main/AndroidManifest.xml create mode 100644 defaultAndroidSettings.gradle create mode 100644 desktop/build.gradle rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/Builder.kt (92%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/utils/FilesHandling.kt (93%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/utils/NewFileFilterFactory.kt (88%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/utils/UIElements.kt (97%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/utils/View.kt (93%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/BuilderView.kt (95%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/DevelopersView.kt (88%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/LicensesView.kt (93%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/ListView.kt (85%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/MavenInfoView.kt (91%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/ProjectTypeView.kt (85%) rename {src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder => desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop}/views/RepositoriesView.kt (86%) rename {src/main => desktop/src/jvmMain}/resources/images/export_gradle.svg (100%) rename {src/main => desktop/src/jvmMain}/resources/images/open_file.svg (100%) rename {src/main => desktop/src/jvmMain}/resources/images/save_as.svg (100%) rename {src/main => desktop/src/jvmMain}/resources/images/save_file.svg (100%) create mode 100644 extensions.gradle create mode 100644 mppAndroidProject.gradle create mode 100644 mppJavaProject.gradle create mode 100644 mppProjectWithSerialization.gradle delete mode 100644 src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/BintrayConfig.kt diff --git a/.gitignore b/.gitignore index 5dc177e..40874d7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ settings.xml .gradle/ build/ out/ + +local.properties diff --git a/build.gradle b/build.gradle index a985521..dbbef1f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,53 +1,31 @@ buildscript { + repositories { + jcenter() + google() + mavenCentral() + mavenLocal() + maven { url "https://plugins.gradle.org/m2/" } + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.0.2' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:$dexcount_version" + classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" + } +} + +allprojects { repositories { mavenLocal() jcenter() mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + google() + maven { url "https://kotlin.bintray.com/kotlinx" } + maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" } } } -plugins { - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" - id("org.jetbrains.compose") version "$compose_version" -} - -apply plugin: 'kotlin' - -project.group = "com.insanusmokrassar" - -repositories { - mavenLocal() - jcenter() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } - maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version" - implementation "dev.inmo:micro_utils.coroutines:$micro_utils_version" - implementation(compose.desktop.currentOs) - - implementation "io.ktor:ktor-client:$ktor_version" - implementation "io.ktor:ktor-client-cio:$ktor_version" -} - -compose.desktop { - application { - mainClass = "com.insanusmokrassar.kmppscriptbuilder.BuilderKt" - } -} - -compileKotlin { - kotlinOptions { - jvmTarget = "11" - useIR = true - } -} +apply from: "./extensions.gradle" +// apply from: "./github_release.gradle" diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..fb2a4c1 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,20 @@ +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" + id "com.android.library" +} + +apply from: "$mppProjectWithSerializationPresetPath" + +kotlin { + sourceSets { + commonMain { + dependencies { + api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" + api "dev.inmo:micro_utils.coroutines:$micro_utils_version" + + api "io.ktor:ktor-client-core:$ktor_version" + } + } + } +} diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/export/jvm_only/MavenTemplater.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/export/jvm_only/MavenTemplater.kt similarity index 94% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/export/jvm_only/MavenTemplater.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/export/jvm_only/MavenTemplater.kt index 8d6b81d..c6995fb 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/export/jvm_only/MavenTemplater.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/export/jvm_only/MavenTemplater.kt @@ -1,6 +1,6 @@ -package com.insanusmokrassar.kmppscriptbuilder.export.jvm_only +package dev.inmo.kmppscriptbuilder.core.export.jvm_only -import com.insanusmokrassar.kmppscriptbuilder.models.* +import dev.inmo.kmppscriptbuilder.core.models.* fun MavenConfig.buildJvmOnlyMavenConfig(licenses: List): String = """ apply plugin: 'maven-publish' diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/export/mpp/MavenTemplater.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/export/mpp/MavenTemplater.kt similarity index 93% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/export/mpp/MavenTemplater.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/export/mpp/MavenTemplater.kt index 188d590..5504384 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/export/mpp/MavenTemplater.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/export/mpp/MavenTemplater.kt @@ -1,6 +1,6 @@ -package com.insanusmokrassar.kmppscriptbuilder.export.mpp +package dev.inmo.kmppscriptbuilder.core.export.mpp -import com.insanusmokrassar.kmppscriptbuilder.models.* +import dev.inmo.kmppscriptbuilder.core.models.* fun MavenConfig.buildMultiplatformMavenConfig(licenses: List): String = """ apply plugin: 'maven-publish' diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/Config.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/Config.kt similarity index 87% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/Config.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/Config.kt index a95d62d..5a644b7 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/Config.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/Config.kt @@ -1,7 +1,7 @@ -package com.insanusmokrassar.kmppscriptbuilder.models +package dev.inmo.kmppscriptbuilder.core.models -import com.insanusmokrassar.kmppscriptbuilder.export.jvm_only.buildJvmOnlyMavenConfig -import com.insanusmokrassar.kmppscriptbuilder.export.mpp.buildMultiplatformMavenConfig +import dev.inmo.kmppscriptbuilder.core.export.jvm_only.buildJvmOnlyMavenConfig +import dev.inmo.kmppscriptbuilder.core.export.mpp.buildMultiplatformMavenConfig import kotlinx.serialization.* import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.SerialDescriptor @@ -16,7 +16,7 @@ sealed class ProjectType { } @Serializer(ProjectType::class) -internal object ProjectTypeSerializer : KSerializer { +object ProjectTypeSerializer : KSerializer { override val descriptor: SerialDescriptor = String.serializer().descriptor override fun deserialize(decoder: Decoder): ProjectType { return when (decoder.decodeString()) { diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/Developer.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/Developer.kt similarity index 73% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/Developer.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/Developer.kt index cc9461a..d8e6708 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/Developer.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/Developer.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.models +package dev.inmo.kmppscriptbuilder.core.models import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/License.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/License.kt similarity index 93% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/License.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/License.kt index f7a3811..5ce25f9 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/License.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/License.kt @@ -1,6 +1,6 @@ -package com.insanusmokrassar.kmppscriptbuilder.models +package dev.inmo.kmppscriptbuilder.core.models -import com.insanusmokrassar.kmppscriptbuilder.utils.serialFormat +import dev.inmo.kmppscriptbuilder.core.utils.serialFormat import io.ktor.client.HttpClient import io.ktor.client.request.get import io.ktor.client.request.url diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/MavenConfig.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/MavenConfig.kt similarity index 95% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/MavenConfig.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/MavenConfig.kt index d2512fd..32d9c0e 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/MavenConfig.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/models/MavenConfig.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.models +package dev.inmo.kmppscriptbuilder.core.models import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/SerialFormat.kt b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/utils/SerialFormat.kt similarity index 64% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/SerialFormat.kt rename to core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/utils/SerialFormat.kt index 1e8e62b..f465ab1 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/SerialFormat.kt +++ b/core/src/commonMain/kotlin/dev/inmo/kmppscriptbuilder/core/utils/SerialFormat.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.utils +package dev.inmo.kmppscriptbuilder.core.utils import kotlinx.serialization.json.Json diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e3cc55a --- /dev/null +++ b/core/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/defaultAndroidSettings.gradle b/defaultAndroidSettings.gradle new file mode 100644 index 0000000..79f821a --- /dev/null +++ b/defaultAndroidSettings.gradle @@ -0,0 +1,40 @@ +apply plugin: 'com.getkeepsafe.dexcount' + +android { + compileSdkVersion "$android_compileSdkVersion".toInteger() + buildToolsVersion "$android_buildToolsVersion" + + defaultConfig { + minSdkVersion "$android_minSdkVersion".toInteger() + targetSdkVersion "$android_compileSdkVersion".toInteger() + versionCode "${android_code_version}".toInteger() + versionName "$version" + } + buildTypes { + release { + minifyEnabled false + } + debug { + debuggable true + } + } + + packagingOptions { + exclude 'META-INF/kotlinx-serialization-runtime.kotlin_module' + exclude 'META-INF/kotlinx-serialization-cbor.kotlin_module' + exclude 'META-INF/kotlinx-serialization-properties.kotlin_module' + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } +} diff --git a/desktop/build.gradle b/desktop/build.gradle new file mode 100644 index 0000000..9f7bb5a --- /dev/null +++ b/desktop/build.gradle @@ -0,0 +1,37 @@ +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" + id("org.jetbrains.compose") version "$compose_version" +} + +apply from: "$mppJavaProjectPresetPath" + +kotlin { + jvm { + compilations.main.kotlinOptions { + jvmTarget = "11" + useIR = true + } + } + sourceSets { + commonMain { + dependencies { + implementation project(":kmppscriptbuilder.core") + } + } + + jvmMain { + dependencies { + implementation(compose.desktop.currentOs) + api "io.ktor:ktor-client-cio:$ktor_version" + } + } + } +} + +compose.desktop { + application { + mainClass = "dev.inmo.kmppscriptbuilder.desktop.BuilderKt" + } +} + diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/Builder.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/Builder.kt similarity index 92% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/Builder.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/Builder.kt index 284aa21..d010436 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/Builder.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/Builder.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder +package dev.inmo.kmppscriptbuilder.desktop import androidx.compose.desktop.Window import androidx.compose.foundation.* @@ -7,8 +7,8 @@ import androidx.compose.material.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import com.insanusmokrassar.kmppscriptbuilder.utils.* -import com.insanusmokrassar.kmppscriptbuilder.views.* +import dev.inmo.kmppscriptbuilder.desktop.utils.* +import dev.inmo.kmppscriptbuilder.desktop.views.* import java.io.File //private val uncaughtExceptionsBC = BroadcastChannel(Channel.CONFLATED) diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/FilesHandling.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/FilesHandling.kt similarity index 93% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/FilesHandling.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/FilesHandling.kt index 72b6e04..7869aa7 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/FilesHandling.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/FilesHandling.kt @@ -1,6 +1,7 @@ -package com.insanusmokrassar.kmppscriptbuilder.utils +package dev.inmo.kmppscriptbuilder.desktop.utils -import com.insanusmokrassar.kmppscriptbuilder.models.Config +import dev.inmo.kmppscriptbuilder.core.models.Config +import dev.inmo.kmppscriptbuilder.core.utils.serialFormat import java.io.File import javax.swing.JFileChooser diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/NewFileFilterFactory.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/NewFileFilterFactory.kt similarity index 88% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/NewFileFilterFactory.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/NewFileFilterFactory.kt index 983338c..122d60c 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/NewFileFilterFactory.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/NewFileFilterFactory.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.utils +package dev.inmo.kmppscriptbuilder.desktop.utils import java.io.File import javax.swing.filechooser.FileFilter diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/UIElements.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/UIElements.kt similarity index 97% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/UIElements.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/UIElements.kt index d75fd02..87e9136 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/UIElements.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/UIElements.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.utils +package dev.inmo.kmppscriptbuilder.desktop.utils import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/View.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/View.kt similarity index 93% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/View.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/View.kt index 37cd860..801566f 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/utils/View.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/View.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.utils +package dev.inmo.kmppscriptbuilder.desktop.utils import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/BuilderView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt similarity index 95% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/BuilderView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt index c5e070c..8f3f756 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/BuilderView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.foundation.Image import androidx.compose.foundation.clickable @@ -8,8 +8,8 @@ import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.res.svgResource import androidx.compose.ui.unit.dp -import com.insanusmokrassar.kmppscriptbuilder.models.Config -import com.insanusmokrassar.kmppscriptbuilder.utils.* +import dev.inmo.kmppscriptbuilder.core.models.Config +import dev.inmo.kmppscriptbuilder.desktop.utils.* class BuilderView : View() { private val projectTypeView = ProjectTypeView() diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/DevelopersView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/DevelopersView.kt similarity index 88% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/DevelopersView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/DevelopersView.kt index 8d1accc..14599b8 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/DevelopersView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/DevelopersView.kt @@ -1,8 +1,8 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.runtime.* -import com.insanusmokrassar.kmppscriptbuilder.models.Developer -import com.insanusmokrassar.kmppscriptbuilder.utils.* +import dev.inmo.kmppscriptbuilder.core.models.Developer +import dev.inmo.kmppscriptbuilder.desktop.utils.* class DeveloperState( id: String = "", diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/LicensesView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/LicensesView.kt similarity index 93% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/LicensesView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/LicensesView.kt index 0059027..dff383b 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/LicensesView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/LicensesView.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -7,9 +7,9 @@ import androidx.compose.material.Divider import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.insanusmokrassar.kmppscriptbuilder.models.License -import com.insanusmokrassar.kmppscriptbuilder.models.getLicenses -import com.insanusmokrassar.kmppscriptbuilder.utils.* +import dev.inmo.kmppscriptbuilder.core.models.License +import dev.inmo.kmppscriptbuilder.core.models.getLicenses +import dev.inmo.kmppscriptbuilder.desktop.utils.* import io.ktor.client.HttpClient import kotlinx.coroutines.* diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/ListView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/ListView.kt similarity index 85% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/ListView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/ListView.kt index cec116b..ed6161e 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/ListView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/ListView.kt @@ -1,12 +1,11 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.foundation.layout.* import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.insanusmokrassar.kmppscriptbuilder.models.Developer -import com.insanusmokrassar.kmppscriptbuilder.utils.* +import dev.inmo.kmppscriptbuilder.desktop.utils.* abstract class ListView(title: String) : VerticalView(title) { protected val itemsList = mutableStateListOf() diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/MavenInfoView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/MavenInfoView.kt similarity index 91% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/MavenInfoView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/MavenInfoView.kt index 2c66480..7378550 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/MavenInfoView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/MavenInfoView.kt @@ -1,10 +1,10 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.foundation.layout.ColumnScope import androidx.compose.runtime.* -import com.insanusmokrassar.kmppscriptbuilder.models.MavenConfig -import com.insanusmokrassar.kmppscriptbuilder.models.SonatypeRepository -import com.insanusmokrassar.kmppscriptbuilder.utils.* +import dev.inmo.kmppscriptbuilder.core.models.MavenConfig +import dev.inmo.kmppscriptbuilder.core.models.SonatypeRepository +import dev.inmo.kmppscriptbuilder.desktop.utils.* class MavenInfoView : VerticalView("Project information") { private var projectNameProperty by mutableStateOf("") diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/ProjectTypeView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/ProjectTypeView.kt similarity index 85% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/ProjectTypeView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/ProjectTypeView.kt index 4301668..052b3a4 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/ProjectTypeView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/ProjectTypeView.kt @@ -1,4 +1,4 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.foundation.layout.* import androidx.compose.material.Switch @@ -6,8 +6,8 @@ import androidx.compose.material.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.insanusmokrassar.kmppscriptbuilder.models.* -import com.insanusmokrassar.kmppscriptbuilder.utils.VerticalView +import dev.inmo.kmppscriptbuilder.core.models.* +import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView class ProjectTypeView : VerticalView("Project type") { private var projectTypeState by mutableStateOf(false) diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/RepositoriesView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/RepositoriesView.kt similarity index 86% rename from src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/RepositoriesView.kt rename to desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/RepositoriesView.kt index 78415c9..f76b2cf 100644 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/views/RepositoriesView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/RepositoriesView.kt @@ -1,8 +1,8 @@ -package com.insanusmokrassar.kmppscriptbuilder.views +package dev.inmo.kmppscriptbuilder.desktop.views import androidx.compose.runtime.* -import com.insanusmokrassar.kmppscriptbuilder.models.MavenPublishingRepository -import com.insanusmokrassar.kmppscriptbuilder.utils.* +import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository +import dev.inmo.kmppscriptbuilder.desktop.utils.* class RepositoryState( name: String = "", diff --git a/src/main/resources/images/export_gradle.svg b/desktop/src/jvmMain/resources/images/export_gradle.svg similarity index 100% rename from src/main/resources/images/export_gradle.svg rename to desktop/src/jvmMain/resources/images/export_gradle.svg diff --git a/src/main/resources/images/open_file.svg b/desktop/src/jvmMain/resources/images/open_file.svg similarity index 100% rename from src/main/resources/images/open_file.svg rename to desktop/src/jvmMain/resources/images/open_file.svg diff --git a/src/main/resources/images/save_as.svg b/desktop/src/jvmMain/resources/images/save_as.svg similarity index 100% rename from src/main/resources/images/save_as.svg rename to desktop/src/jvmMain/resources/images/save_as.svg diff --git a/src/main/resources/images/save_file.svg b/desktop/src/jvmMain/resources/images/save_file.svg similarity index 100% rename from src/main/resources/images/save_file.svg rename to desktop/src/jvmMain/resources/images/save_file.svg diff --git a/extensions.gradle b/extensions.gradle new file mode 100644 index 0000000..0c108ed --- /dev/null +++ b/extensions.gradle @@ -0,0 +1,24 @@ +allprojects { + ext { + projectByName = { String name -> + for (subproject in rootProject.subprojects) { + if (subproject.name == name) { + return subproject + } + } + return null + } + + internalProject = { String name -> + projectByName(name) + } + + mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle" + mppJavaProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJavaProject.gradle" + mppAndroidProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppAndroidProject.gradle" + + defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle" + + // publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle" + } +} diff --git a/gradle.properties b/gradle.properties index 55c69b0..0222da4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,35 @@ +kotlin.code.style=official +org.gradle.parallel=true +kotlin.js.generate.externals=true +kotlin.incremental=true +kotlin.incremental.js=true +android.useAndroidX=true +android.enableJetifier=true + kotlin_version=1.4.30 kotlin_coroutines_version=1.4.2 -kotlin_serialisation_runtime_version=1.1.0 -#tornadofx_version=1.7.20 +kotlin_serialisation_core_version=1.1.0 ktor_version=1.5.1 -micro_utils_version=0.4.25 - -javafxplugin_version=0.0.9 +micro_utils_version=0.4.27 compose_version=0.3.0 + +# ANDROID + +android_minSdkVersion=21 +android_compileSdkVersion=30 +android_buildToolsVersion=30.0.2 +dexcount_version=2.0.0 +junit_version=4.12 +test_ext_junit_version=1.1.2 +espresso_core=3.3.0 + +# Dokka + +dokka_version=1.4.20 + +# Project data + +group=dev.inmo +version=0.0.1 +android_code_version=1 diff --git a/mppAndroidProject.gradle b/mppAndroidProject.gradle new file mode 100644 index 0000000..20b6516 --- /dev/null +++ b/mppAndroidProject.gradle @@ -0,0 +1,26 @@ +project.version = "$version" + System.getenv("additional_version") +project.group = "$group" + +// apply from: "$publishGradlePath" + +kotlin { + android { + publishAllLibraryVariants() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + } + } + commonTest { + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + } + } + } +} + +apply from: "$defaultAndroidSettingsPresetPath" diff --git a/mppJavaProject.gradle b/mppJavaProject.gradle new file mode 100644 index 0000000..2f64097 --- /dev/null +++ b/mppJavaProject.gradle @@ -0,0 +1,30 @@ +project.version = "$version" + System.getenv("additional_version") +project.group = "$group" + +// apply from: "$publishGradlePath" + +kotlin { + jvm { + compilations.main.kotlinOptions.useIR = true + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + } + } + commonTest { + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + } + } + + jvmTest { + dependencies { + implementation kotlin('test-junit') + } + } + } +} diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle new file mode 100644 index 0000000..72b6115 --- /dev/null +++ b/mppProjectWithSerialization.gradle @@ -0,0 +1,52 @@ +project.version = "$version" + System.getenv("additional_version") +project.group = "$group" + +// apply from: "$publishGradlePath" + +kotlin { + jvm { + compilations.main.kotlinOptions.useIR = true + } + js (IR) { + browser() + nodejs() + } + android { + publishAllLibraryVariants() + } + + sourceSets { + commonMain { + dependencies { + implementation kotlin('stdlib') + api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_core_version" + } + } + commonTest { + dependencies { + implementation kotlin('test-common') + implementation kotlin('test-annotations-common') + } + } + jvmTest { + dependencies { + implementation kotlin('test-junit') + } + } + jsTest { + dependencies { + implementation kotlin('test-js') + implementation kotlin('test-junit') + } + } + androidTest { + dependencies { + implementation kotlin('test-junit') + implementation "androidx.test.ext:junit:$test_ext_junit_version" + implementation "androidx.test.espresso:espresso-core:$espresso_core" + } + } + } +} + +apply from: "$defaultAndroidSettingsPresetPath" diff --git a/settings.gradle b/settings.gradle index 1660178..b1eed1e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,4 +5,21 @@ pluginManagement { } } -rootProject.name = 'KotlinPublicationScriptsBuilder' +rootProject.name = 'kmppscriptbuilder' + +String[] includes = [ + ":core", + ":desktop" +] + + +includes.each { originalName -> + String projectDirectory = "${rootProject.projectDir.getAbsolutePath()}${originalName.replaceAll(":", File.separator)}" + String projectName = "${rootProject.name}${originalName.replaceAll(":", ".")}" + String projectIdentifier = ":${projectName}" + include projectIdentifier + ProjectDescriptor project = project(projectIdentifier) + project.name = projectName + project.projectDir = new File(projectDirectory) +} + diff --git a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/BintrayConfig.kt b/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/BintrayConfig.kt deleted file mode 100644 index 19eccc6..0000000 --- a/src/main/kotlin/com/insanusmokrassar/kmppscriptbuilder/models/BintrayConfig.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.insanusmokrassar.kmppscriptbuilder.models - -import kotlinx.serialization.Serializable - -@Serializable -data class BintrayConfig( - val repoUser: String = "\${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}", - val repo: String, - val packageName: String, - val packageVcs: String, - val autoPublish: Boolean = false, - val overridePublish: Boolean = false -)