From e18e8ba6df87041bb341a8feb78dc1405ff6f048 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 29 Jun 2022 13:47:21 +0600 Subject: [PATCH] start to use more unified way of scripts organization --- build.gradle | 16 ++--- docs/build.gradle | 2 +- extensions.gradle | 8 +++ gradle/libs.versions.toml | 26 ++++++++ mppJsProject.gradle | 32 ++++++++++ mppProjectWithSerialization.gradle | 49 +++++++++++++++ tgbotapi.api/build.gradle | 39 +----------- tgbotapi.behaviour_builder.fsm/build.gradle | 41 +------------ tgbotapi.behaviour_builder/build.gradle | 39 +----------- tgbotapi.core/build.gradle | 67 +++------------------ tgbotapi.utils/build.gradle | 57 +----------------- tgbotapi.webapps/build.gradle | 40 +----------- 12 files changed, 139 insertions(+), 277 deletions(-) create mode 100644 extensions.gradle create mode 100644 gradle/libs.versions.toml create mode 100644 mppJsProject.gradle create mode 100644 mppProjectWithSerialization.gradle diff --git a/build.gradle b/build.gradle index 42562e8321..a953b15edf 100644 --- a/build.gradle +++ b/build.gradle @@ -6,19 +6,20 @@ buildscript { } dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath libs.kotlin.gradle.plugin + classpath libs.kotlin.serialization.plugin + classpath libs.kotlin.dokka.plugin classpath "com.github.breadmoirai:github-release:$github_release_plugin_version" } } -plugins { - id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false - id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false -} - // temporal crutch until legacy tests will be stabled or legacy target will be removed allprojects { + repositories { + mavenLocal() + mavenCentral() + google() + } if (it != rootProject.findProject("docs")) { tasks.whenTaskAdded { task -> if(task.name == "jsLegacyBrowserTest" || task.name == "jsLegacyNodeTest") { @@ -27,6 +28,7 @@ allprojects { } } } +apply from: "./extensions.gradle" private String getCurrentVersionChangelog() { OutputStream changelogDataOS = new ByteArrayOutputStream() diff --git a/docs/build.gradle b/docs/build.gradle index 460bce0fc3..5a567aa1e2 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -14,7 +14,7 @@ buildscript { plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" - id "org.jetbrains.dokka" version "$dokka_version" + id "org.jetbrains.dokka" } repositories { diff --git a/extensions.gradle b/extensions.gradle new file mode 100644 index 0000000000..bbe44c025d --- /dev/null +++ b/extensions.gradle @@ -0,0 +1,8 @@ +allprojects { + ext { + mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle" + mppJsProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJsProject.gradle" + + publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle" + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000000..334dea6b0f --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,26 @@ +[versions] + +kotlin = "1.6.21" +kotlin-serialization = "1.3.3" +kotlin-gradle-plugin = "7.0.4" + +[libraries] + +kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-serialization" } +kotlin-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" } +kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" } +kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } +kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kotlin" } + +# buildscript classpaths + +android-tools-build = { module = "com.android.tools.build:gradle", version.ref = "kotlin-gradle-plugin" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" } +kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" } + +[plugins] + +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } diff --git a/mppJsProject.gradle b/mppJsProject.gradle new file mode 100644 index 0000000000..f7499b3c3b --- /dev/null +++ b/mppJsProject.gradle @@ -0,0 +1,32 @@ +project.version = "$version" +project.group = "$group" + +apply from: "$publishGradlePath" + +kotlin { + js (IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation libs.kotlin + api libs.kotlin.serialization + } + } + commonTest { + dependencies { + implementation libs.kotlin.test.common + implementation libs.kotlin.test.annotations.common + } + } + jsTest { + dependencies { + implementation libs.kotlin.test.js + implementation libs.kotlin.test.junit + } + } + } +} diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle new file mode 100644 index 0000000000..eba900f32b --- /dev/null +++ b/mppProjectWithSerialization.gradle @@ -0,0 +1,49 @@ +project.version = "$library_version" +project.group = "$library_group" + +apply from: "$publishGradlePath" + +kotlin { + jvm { + compilations.main { + kotlinOptions { + jvmTarget = "1.8" + } + } + } + js (IR) { + browser() + nodejs() + } + + sourceSets { + commonMain { + dependencies { + implementation libs.kotlin + api libs.kotlin.serialization + } + } + commonTest { + dependencies { + implementation libs.kotlin.test.common + implementation libs.kotlin.test.annotations.common + } + } + jvmTest { + dependencies { + implementation libs.kotlin.test.junit + } + } + jsTest { + dependencies { + implementation libs.kotlin.test.js + implementation libs.kotlin.test.junit + } + } + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/tgbotapi.api/build.gradle b/tgbotapi.api/build.gradle index f6d1e00bcf..a8733e81fb 100644 --- a/tgbotapi.api/build.gradle +++ b/tgbotapi.api/build.gradle @@ -1,56 +1,19 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" } -project.version = "$library_version" -project.group = "$library_group" project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor" -apply from: "../publish.gradle" - -repositories { - mavenLocal() - mavenCentral() -} +apply from: "$mppProjectWithSerializationPresetPath" kotlin { - jvm { - compilations.main { - kotlinOptions { - jvmTarget = "1.8" - } - } - } - js(IR) { - browser() - nodejs() - } - sourceSets { commonMain { dependencies { - implementation kotlin('stdlib') api project(":tgbotapi.core") } } } } -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} - diff --git a/tgbotapi.behaviour_builder.fsm/build.gradle b/tgbotapi.behaviour_builder.fsm/build.gradle index 1a2d2cc76d..271970635b 100644 --- a/tgbotapi.behaviour_builder.fsm/build.gradle +++ b/tgbotapi.behaviour_builder.fsm/build.gradle @@ -1,56 +1,19 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" } -project.version = "$library_version" -project.group = "$library_group" -project.description = "Behaviour Builder extension with built-in FSM" +project.description = "Behaviour Builder DSL" -apply from: "../publish.gradle" - -repositories { - mavenLocal() - mavenCentral() -} +apply from: "$mppProjectWithSerializationPresetPath" kotlin { - jvm { - compilations.main { - kotlinOptions { - jvmTarget = "1.8" - } - } - } - js(IR) { - browser() - nodejs() - } - sourceSets { commonMain { dependencies { - implementation kotlin('stdlib') api project(":tgbotapi.behaviour_builder") api "dev.inmo:micro_utils.fsm.common:$micro_utils_version" } } } } - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/tgbotapi.behaviour_builder/build.gradle b/tgbotapi.behaviour_builder/build.gradle index 68224e8bc7..9f6ea76c57 100644 --- a/tgbotapi.behaviour_builder/build.gradle +++ b/tgbotapi.behaviour_builder/build.gradle @@ -1,55 +1,18 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" } -project.version = "$library_version" -project.group = "$library_group" project.description = "Behaviour Builder DSL" -apply from: "../publish.gradle" - -repositories { - mavenLocal() - mavenCentral() -} +apply from: "$mppProjectWithSerializationPresetPath" kotlin { - jvm { - compilations.main { - kotlinOptions { - jvmTarget = "1.8" - } - } - } - js(IR) { - browser() - nodejs() - } - sourceSets { commonMain { dependencies { - implementation kotlin('stdlib') api project(":tgbotapi.utils") } } } } - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index 28889e2fb0..a9ba153e57 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -1,48 +1,16 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" } -project.version = "$library_version" -project.group = "$library_group" project.description = "Core part of tgbotapi with all (and only) required functionality for working with Telegram Bot API" -apply from: "../publish.gradle" - -repositories { - mavenLocal() - mavenCentral() -} +apply from: "$mppProjectWithSerializationPresetPath" kotlin { - jvm { - compilations.main { - kotlinOptions { - jvmTarget = "1.8" - } - } - } - js(IR) { - browser() - nodejs() - } - sourceSets { commonMain { dependencies { - implementation kotlin('stdlib') api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version" api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version" @@ -63,12 +31,9 @@ kotlin { } commonTest { dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') implementation project(":tgbotapi.utils") } } - jvmMain { dependencies { api "io.ktor:ktor-server:$ktor_version" @@ -79,29 +44,13 @@ kotlin { api "javax.activation:activation:$javax_activation_version" } } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsTest { - dependencies { - implementation kotlin('test-junit') - implementation kotlin('test-js') - } - } } - targets.all { - compilations.all { - kotlinOptions { - freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"] - } - } - } -} - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 +// targets.all { +// compilations.all { +// kotlinOptions { +// freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"] +// } +// } +// } } diff --git a/tgbotapi.utils/build.gradle b/tgbotapi.utils/build.gradle index d84f636549..a860a8e6e2 100644 --- a/tgbotapi.utils/build.gradle +++ b/tgbotapi.utils/build.gradle @@ -1,73 +1,18 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" } -project.version = "$library_version" -project.group = "$library_group" project.description = "Additional extensions for core part of tgbotapi" -apply from: "../publish.gradle" - -repositories { - mavenLocal() - mavenCentral() -} +apply from: "$mppProjectWithSerializationPresetPath" kotlin { - jvm { - compilations.main { - kotlinOptions { - jvmTarget = "1.8" - } - } - } - js(IR) { - browser() - nodejs() - } - sourceSets { commonMain { dependencies { - implementation kotlin('stdlib') api project(":tgbotapi.core") } } - - commonTest { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - jvmTest { - dependencies { - implementation kotlin('test-junit') - } - } - jsTest { - dependencies { - implementation kotlin('test-junit') - implementation kotlin('test-js') - } - } } } - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} diff --git a/tgbotapi.webapps/build.gradle b/tgbotapi.webapps/build.gradle index 951c331574..ca80bfe22b 100644 --- a/tgbotapi.webapps/build.gradle +++ b/tgbotapi.webapps/build.gradle @@ -1,56 +1,18 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - } -} - plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.plugin.serialization" } -project.version = "$library_version" -project.group = "$library_group" project.description = "Web App bindings for the Telegram Web Apps API" -apply from: "../publish.gradle" - -repositories { - mavenLocal() - mavenCentral() -} +apply from: "$mppProjectWithSerializationPresetPath" kotlin { - jvm { - compilations.main { - kotlinOptions { - jvmTarget = "1.8" - } - } - } - js(IR) { - browser() - nodejs() - } - sourceSets { commonMain { dependencies { - implementation kotlin('stdlib') api project(":tgbotapi.core") } } } } - -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} -