From d418cf943237eca32aac976cda0cf6e13c61e047 Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Tue, 2 Jul 2024 09:41:33 +0200 Subject: [PATCH] feat: Config all modules to publish to maven with custom publish plugin --- Common/build.gradle.kts | 16 +++++++--------- Core/build.gradle.kts | 23 ++++++++++++----------- DB/build.gradle.kts | 24 ++++++++++++++---------- Network/build.gradle.kts | 21 ++++++++++----------- build.gradle.kts | 9 --------- gradle/libs.versions.toml | 7 ++++++- 6 files changed, 49 insertions(+), 51 deletions(-) diff --git a/Common/build.gradle.kts b/Common/build.gradle.kts index 5e960869..d390f58b 100644 --- a/Common/build.gradle.kts +++ b/Common/build.gradle.kts @@ -1,3 +1,4 @@ +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -7,15 +8,11 @@ plugins { alias(libs.plugins.androidLibrary) } -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra - kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } } @@ -37,6 +34,7 @@ kotlin { sourceSets { commonMain.dependencies { api(libs.kotlinx.coroutines.core) + api(libs.kotlinx.datetime) } commonTest.dependencies { implementation(libs.kotlin.test) @@ -46,12 +44,12 @@ kotlin { android { namespace = "com.infomaniak.multiplatform_swisstransfer.common" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/Core/build.gradle.kts b/Core/build.gradle.kts index 57cbd09f..39f26656 100644 --- a/Core/build.gradle.kts +++ b/Core/build.gradle.kts @@ -1,4 +1,6 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishPlugin +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -8,18 +10,17 @@ plugins { alias(libs.plugins.androidLibrary) alias(libs.plugins.skie) } - -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra -val skieMaxArgumentCount: Int by rootProject.extra +apply() kotlin { + withSourcesJar(publish = false) androidTarget { + withSourcesJar(publish = true) @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } + publishLibraryVariants("release") } val xcframeworkName = "Core" @@ -55,7 +56,7 @@ skie { features { group { DefaultArgumentInterop.Enabled(true) - DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount) + DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount) } } build { @@ -65,12 +66,12 @@ skie { android { namespace = "com.infomaniak.multiplatform_swisstransfer" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/DB/build.gradle.kts b/DB/build.gradle.kts index f21161c3..0f395143 100644 --- a/DB/build.gradle.kts +++ b/DB/build.gradle.kts @@ -1,4 +1,7 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishExtension.Companion.publishConfig +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishPlugin +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -9,18 +12,19 @@ plugins { alias(libs.plugins.realm) alias(libs.plugins.skie) } +apply() -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra -val skieMaxArgumentCount: Int by rootProject.extra +publishConfig { + mavenName = "database" +} kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } + publishLibraryVariants("release") } val xcframeworkName = "DB" @@ -55,7 +59,7 @@ skie { features { group { DefaultArgumentInterop.Enabled(true) - DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount) + DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount) } } build { @@ -65,12 +69,12 @@ skie { android { namespace = "com.infomaniak.multiplatform_swisstransfer.db" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/Network/build.gradle.kts b/Network/build.gradle.kts index cfcec717..658ff2a8 100644 --- a/Network/build.gradle.kts +++ b/Network/build.gradle.kts @@ -1,4 +1,6 @@ import co.touchlab.skie.configuration.DefaultArgumentInterop +import com.infomaniak.multiplatform_swisstranfer.gradle.PublishPlugin +import com.infomaniak.multiplatform_swisstranfer.utils.Versions import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework @@ -9,18 +11,15 @@ plugins { kotlin("plugin.serialization") version libs.versions.kotlin alias(libs.plugins.skie) } - -val sharedMinSdk: Int by rootProject.extra -val sharedCompileSdk: Int by rootProject.extra -val javaVersion: JavaVersion by rootProject.extra -val skieMaxArgumentCount: Int by rootProject.extra +apply() kotlin { androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { - jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString())) + jvmTarget.set(JvmTarget.fromTarget(Versions.javaVersion.toString())) } + publishLibraryVariants("release") } val xcframeworkName = "Network" @@ -65,7 +64,7 @@ skie { features { group { DefaultArgumentInterop.Enabled(true) - DefaultArgumentInterop.MaximumDefaultArgumentCount(skieMaxArgumentCount) + DefaultArgumentInterop.MaximumDefaultArgumentCount(Versions.skieMaxArgumentCount) } } build { @@ -75,12 +74,12 @@ skie { android { namespace = "com.infomaniak.multiplatform_swisstransfer.network" - compileSdk = sharedCompileSdk + compileSdk = Versions.compileSdk defaultConfig { - minSdk = sharedMinSdk + minSdk = Versions.minSdk } compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = Versions.javaVersion + targetCompatibility = Versions.javaVersion } } diff --git a/build.gradle.kts b/build.gradle.kts index df430257..520f27d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,3 @@ -buildscript { - extra.apply { - set("sharedMinSdk", 24) - set("sharedCompileSdk", 34) - set("javaVersion", JavaVersion.VERSION_17) - set("skieMaxArgumentCount", 7) - } -} - plugins { alias(libs.plugins.androidLibrary).apply(false) alias(libs.plugins.kotlinMultiplatform).apply(false) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9798a45b..9c20e480 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,8 @@ [versions] -agp = "8.4.1" +agp = "8.4.2" coroutines = "1.8.1" kotlin = "2.0.0" +kotlinxDatetime = "0.6.0" kotlinxSerializationJson = "1.7.0" ktor = "2.3.11" realm = "2.0.0" @@ -10,9 +11,13 @@ skie = "0.8.2" [libraries] kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } +ktor-client-content-negociation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" } +ktor-client-encoding = { module = "io.ktor:ktor-client-encoding", version.ref = "ktor" } +ktor-client-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } realm-base = { module = "io.realm.kotlin:library-base", version.ref = "realm" } #Test