Код: Выделить всё
class TemperatureConverter {
fun celsiusToFahrenheit(celsius: Double): Double {
return celsius * 1.8 + 32.0
}
fun fahrenheitToCelsius(fahrenheit: Double): Double {
return (fahrenheit - 32.0) / 1.8
}
val simpleString : String = "SimpleString"
}
Код: Выделить всё
plugins {
id("com.android.library").version("8.0.2").apply(false)
kotlin("multiplatform").version("1.9.24").apply(false)
id("maven-publish")
}
buildscript {
repositories {
google()
mavenCentral()
mavenLocal()
}
}
afterEvaluate {
publishing {
publications {
create("release") {
groupId = "com.ag.secondTry"
artifactId = "test-lib-second"
version = "1.0.13"
artifact("C:\\KotlinSamples\\KotlinLibs\\TestLib\\sharedMpTest\\build\\outputs\\aar\\sharedMpTest-debug.aar")
}
}
}
}
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
maven { url = uri("https://jitpack.io") }
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
Код: Выделить всё
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("maven-publish")
}
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
applyDefaultHierarchyTemplate()
androidTarget {
publishLibraryVariants("release", "debug")
compilations.all {
kotlinOptions {
jvmTarget = "17"
}
}
}
androidTarget()
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "14.1"
framework {
baseName = "sharedMpTest"
}
}
sourceSets {
val commonMain by getting {
dependencies {
//put your multiplatform dependencies here
}
}
}
}
android {
namespace = "com.ag.kmmtestlib"
compileSdk = 33
defaultConfig {
minSdk = 21
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
если я удалю артефакт из build.gradle.kts, библиотека не появится во внешних библиотеках проекта, к которому я ее подключаю.
Подробнее здесь: https://stackoverflow.com/questions/786 ... commonmain