From e8a280c90d88255d1bdba0ef13dc0bb0d139a0fd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 30 Aug 2024 00:51:03 +0600 Subject: [PATCH] small optimization of extensions.gradle --- docs/build.gradle | 2 +- extensions.gradle | 19 ++++++++++++++----- .../templates/mppJsProject.gradle | 2 +- .../mppProjectWithSerialization.gradle | 0 .../templates/mpp_publish.gradle | 0 .../templates/mpp_publish.kpsb | 0 tgbotapi.api/build.gradle | 4 ++-- tgbotapi.behaviour_builder.fsm/build.gradle | 4 ++-- tgbotapi.behaviour_builder/build.gradle | 4 ++-- tgbotapi.core/build.gradle | 4 ++-- tgbotapi.utils/build.gradle | 4 ++-- tgbotapi.webapps/build.gradle | 4 ++-- tgbotapi/build.gradle | 4 ++-- 13 files changed, 30 insertions(+), 21 deletions(-) rename mppJsProject.gradle => gradle/templates/mppJsProject.gradle (94%) rename mppProjectWithSerialization.gradle => gradle/templates/mppProjectWithSerialization.gradle (100%) rename publish.gradle => gradle/templates/mpp_publish.gradle (100%) rename publish.kpsb => gradle/templates/mpp_publish.kpsb (100%) diff --git a/docs/build.gradle b/docs/build.gradle index 6cc0fbad7e..74dda168ee 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -6,7 +6,7 @@ plugins { project.description = "Full collection of all built-in tgbotapi tools" -apply from: "$mppProjectWithSerializationPresetPath" +apply from: "$mppProjectWithSerialization" kotlin { sourceSets { diff --git a/extensions.gradle b/extensions.gradle index bbe44c025d..a007808ada 100644 --- a/extensions.gradle +++ b/extensions.gradle @@ -1,8 +1,17 @@ -allprojects { - ext { - mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle" - mppJsProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJsProject.gradle" +File templatesFolder = new File("$rootProject.projectDir.absolutePath${File.separatorChar}gradle${File.separatorChar}templates") - publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle" +Map properties = new HashMap() + +if (templatesFolder.exists() && templatesFolder.isDirectory()) { + templatesFolder.listFiles().each { + properties[it.name - ".gradle"] = it.absolutePath + } +} + +allprojects { + ext { + properties.forEach { k, v -> + it[k] = v + } } } diff --git a/mppJsProject.gradle b/gradle/templates/mppJsProject.gradle similarity index 94% rename from mppJsProject.gradle rename to gradle/templates/mppJsProject.gradle index 5e0b8b40e3..13ad27e45f 100644 --- a/mppJsProject.gradle +++ b/gradle/templates/mppJsProject.gradle @@ -1,7 +1,7 @@ project.version = "$version" project.group = "$group" -apply from: "$publishGradlePath" +apply from: "$mpp_publish" kotlin { js (IR) { diff --git a/mppProjectWithSerialization.gradle b/gradle/templates/mppProjectWithSerialization.gradle similarity index 100% rename from mppProjectWithSerialization.gradle rename to gradle/templates/mppProjectWithSerialization.gradle diff --git a/publish.gradle b/gradle/templates/mpp_publish.gradle similarity index 100% rename from publish.gradle rename to gradle/templates/mpp_publish.gradle diff --git a/publish.kpsb b/gradle/templates/mpp_publish.kpsb similarity index 100% rename from publish.kpsb rename to gradle/templates/mpp_publish.kpsb diff --git a/tgbotapi.api/build.gradle b/tgbotapi.api/build.gradle index 1e1e2a6a8f..fe20b4d6bb 100644 --- a/tgbotapi.api/build.gradle +++ b/tgbotapi.api/build.gradle @@ -6,8 +6,8 @@ plugins { project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets { diff --git a/tgbotapi.behaviour_builder.fsm/build.gradle b/tgbotapi.behaviour_builder.fsm/build.gradle index fb7c09bced..1eca651112 100644 --- a/tgbotapi.behaviour_builder.fsm/build.gradle +++ b/tgbotapi.behaviour_builder.fsm/build.gradle @@ -6,8 +6,8 @@ plugins { project.description = "Behaviour Builder DSL" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets { diff --git a/tgbotapi.behaviour_builder/build.gradle b/tgbotapi.behaviour_builder/build.gradle index cb0e6bcca1..7347620a8e 100644 --- a/tgbotapi.behaviour_builder/build.gradle +++ b/tgbotapi.behaviour_builder/build.gradle @@ -6,8 +6,8 @@ plugins { project.description = "Behaviour Builder DSL" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets { diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index 51ee82808d..1740d84192 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -7,8 +7,8 @@ plugins { project.description = "Core part of tgbotapi with all (and only) required functionality for working with Telegram Bot API" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets { diff --git a/tgbotapi.utils/build.gradle b/tgbotapi.utils/build.gradle index 69aeb7a1fe..05f533483e 100644 --- a/tgbotapi.utils/build.gradle +++ b/tgbotapi.utils/build.gradle @@ -6,8 +6,8 @@ plugins { project.description = "Additional extensions for core part of tgbotapi" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets { diff --git a/tgbotapi.webapps/build.gradle b/tgbotapi.webapps/build.gradle index bed7c0e918..9a17703fe8 100644 --- a/tgbotapi.webapps/build.gradle +++ b/tgbotapi.webapps/build.gradle @@ -6,8 +6,8 @@ plugins { project.description = "Web App bindings for the Telegram Web Apps API" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets { diff --git a/tgbotapi/build.gradle b/tgbotapi/build.gradle index 5194d4f289..4790fa6042 100644 --- a/tgbotapi/build.gradle +++ b/tgbotapi/build.gradle @@ -6,8 +6,8 @@ plugins { project.description = "Full collection of all built-in tgbotapi tools" -apply from: "$mppProjectWithSerializationPresetPath" -apply from: "$publishGradlePath" +apply from: "$mppProjectWithSerialization" +apply from: "$mpp_publish" kotlin { sourceSets {