diff --git a/InlineQueriesBot/build.gradle b/InlineQueriesBot/build.gradle
index a574fb8..bf06c00 100644
--- a/InlineQueriesBot/build.gradle
+++ b/InlineQueriesBot/build.gradle
@@ -16,15 +16,9 @@ apply plugin: 'application'
 
 mainClassName="InlineQueriesBotKt"
 
+apply from: "$nativePartTemplate"
 
 kotlin {
-    def hostOs = System.getProperty("os.name")
-    def isMingwX64 = hostOs.startsWith("Windows")
-    def nativeTarget
-    if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries { executable() } }
-    else if (isMingwX64) nativeTarget = mingwX64("native") { binaries { executable() } }
-    else throw new GradleException("Host OS is not supported in Kotlin/Native.")
-
     jvm()
 
     sourceSets {
@@ -35,18 +29,6 @@ kotlin {
                 api "dev.inmo:tgbotapi:$telegram_bot_api_version"
             }
         }
-
-        nativeMain {
-            dependencies {
-                def engine
-
-                if (hostOs == "Linux") engine = "curl"
-                else if (isMingwX64) engine = "winhttp"
-                else throw new GradleException("Host OS is not supported in Kotlin/Native.")
-
-                api "io.ktor:ktor-client-$engine:$ktor_version"
-            }
-        }
     }
 }
 
diff --git a/RandomFileSenderBot/build.gradle b/RandomFileSenderBot/build.gradle
index 70327df..ffc31e6 100644
--- a/RandomFileSenderBot/build.gradle
+++ b/RandomFileSenderBot/build.gradle
@@ -16,15 +16,9 @@ apply plugin: 'application'
 
 mainClassName="RandomFileSenderBotKt"
 
+apply from: "$nativePartTemplate"
 
 kotlin {
-    def hostOs = System.getProperty("os.name")
-    def isMingwX64 = hostOs.startsWith("Windows")
-    def nativeTarget
-    if (hostOs == "Linux") nativeTarget = linuxX64("native") { binaries { executable() } }
-    else if (isMingwX64) nativeTarget = mingwX64("native") { binaries { executable() } }
-    else throw new GradleException("Host OS is not supported in Kotlin/Native.")
-
     jvm()
 
     sourceSets {
@@ -35,18 +29,6 @@ kotlin {
                 api "dev.inmo:tgbotapi:$telegram_bot_api_version"
             }
         }
-
-        nativeMain {
-            dependencies {
-                def engine
-
-                if (hostOs == "Linux") engine = "curl"
-                else if (isMingwX64) engine = "winhttp"
-                else throw new GradleException("Host OS is not supported in Kotlin/Native.")
-
-                api "io.ktor:ktor-client-$engine:$ktor_version"
-            }
-        }
     }
 }
 
diff --git a/ResenderBot/native_launcher/build.gradle b/ResenderBot/native_launcher/build.gradle
index b5314cd..0adba7a 100644
--- a/ResenderBot/native_launcher/build.gradle
+++ b/ResenderBot/native_launcher/build.gradle
@@ -12,26 +12,9 @@ plugins {
     id "org.jetbrains.kotlin.multiplatform"
 }
 
+apply from: "$nativePartTemplate"
 
 kotlin {
-    def hostOs = System.getProperty("os.name")
-    def isMingwX64 = hostOs.startsWith("Windows")
-    def isArch64 = System.getProperty("os.arch") == "aarch64"
-    def nativeTarget
-    if (hostOs == "Linux") {
-        if (isArch64) {
-            nativeTarget = linuxArm64("native") { binaries { executable() } }
-        } else {
-            nativeTarget = linuxX64("native") { binaries { executable() } }
-        }
-    } else {
-        if (isMingwX64) {
-            nativeTarget = mingwX64("native") { binaries { executable() } }
-        } else {
-            throw new GradleException("Host OS is not supported in Kotlin/Native.")
-        }
-    }
-
     sourceSets {
         commonMain {
             dependencies {
@@ -40,18 +23,6 @@ kotlin {
                 api project(":ResenderBot:ResenderBotLib")
             }
         }
-
-        nativeMain {
-            dependencies {
-                def engine
-
-                if (hostOs == "Linux") engine = "curl"
-                else if (isMingwX64) engine = "winhttp"
-                else throw new GradleException("Host OS is not supported in Kotlin/Native.")
-
-                api "io.ktor:ktor-client-$engine:$ktor_version"
-            }
-        }
     }
 }
 
diff --git a/build.gradle b/build.gradle
index 7499d2f..f0319eb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,6 +10,9 @@ buildscript {
 }
 
 allprojects {
+    ext {
+        nativePartTemplate = "${rootProject.projectDir.absolutePath}/native_template.gradle"
+    }
     repositories {
         mavenLocal()
         mavenCentral()
diff --git a/native_template.gradle b/native_template.gradle
new file mode 100644
index 0000000..12cffdd
--- /dev/null
+++ b/native_template.gradle
@@ -0,0 +1,34 @@
+kotlin {
+    def hostOs = System.getProperty("os.name")
+    def isMingwX64 = hostOs.startsWith("Windows")
+    def isArch64 = System.getProperty("os.arch") == "aarch64"
+
+    def nativeTarget
+    if (hostOs == "Linux") {
+        if (isArch64) {
+            nativeTarget = linuxArm64("native") { binaries { executable() } }
+        } else {
+            nativeTarget = linuxX64("native") { binaries { executable() } }
+        }
+    } else {
+        if (isMingwX64) {
+            nativeTarget = mingwX64("native") { binaries { executable() } }
+        } else {
+            throw new GradleException("Host OS is not supported in Kotlin/Native.")
+        }
+    }
+
+    sourceSets {
+        nativeMain {
+            dependencies {
+                def engine
+
+                if (hostOs == "Linux") if (isArch64) engine = "cio" else engine = "curl"
+                else if (isMingwX64) engine = "winhttp"
+                else throw new GradleException("Host OS is not supported in Kotlin/Native.")
+
+                api "io.ktor:ktor-client-$engine:$ktor_version"
+            }
+        }
+    }
+}